【发布时间】:2012-04-20 13:03:11
【问题描述】:
我在 UIPopoverController 中添加了一个按钮,但它似乎对触摸没有响应。我不知道我是否应该在 UIPopoverController 上设置一些属性或什么。这是呈现弹出视图和按钮的代码。
- (void)topicImageButtonPressed
{
CGRect aFrame = CGRectMake(0.0, 0.0, 1000.0, 600.0);
UIViewController *aView = [[UIViewController alloc] init];
aView.view.frame = aFrame;
UIImageView *iView = [[UIImageView alloc] init];
[iView setContentMode:UIViewContentModeScaleAspectFit];
[iView setImage:self.topicImageView1.image];
aView.view = iView;
UIButton *nextButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[nextButton addTarget:self
action:@selector(quizButtonPressed:)
forControlEvents:UIControlEventTouchUpInside];
[nextButton setTitle:@"Next" forState:UIControlStateNormal];
nextButton.frame = CGRectMake(700.0, 550.0, 160.0, 40.0);
[aView.view addSubview:nextButton];
//aView.view.backgroundColor = [UIColor colorWithPatternImage:self.topicImageView1.image];
imagePopoverController = [[UIPopoverController alloc]
initWithContentViewController:aView];
imagePopoverController.popoverContentSize = CGSizeMake(1000, 600);
imagePopoverController.passthroughViews = [NSArray arrayWithObject:nextButton];
[imagePopoverController presentPopoverFromRect:CGRectMake(212, 10, 1000, 600) inView:self.view
permittedArrowDirections:0 animated:YES];
}
【问题讨论】:
-
是这个问题吗,你的按钮正在触地但没有可见的视图?
-
按钮未获得触摸事件。我向它添加了一个 NSLog 语句,以查看它是否被触及。
标签: iphone ios ipad uiviewcontroller uipopovercontroller