0
当我在ViewDidLoad
方法中添加UIPopoverController
时,它显示一个空的弹窗视图。当我添加一个UITapGestureRecognizer
时会发生同样的事情;它不触发附加的方法。如果我将代码放在我的ViewDidAppear
中,它确实有效,但在某些情况下,从不会调用ViewDidAppear
,具体取决于视图在故事板中的加载位置。UIPopoverController和UITapGestureRecognizer在ViewDidLoad中不工作
这里是我的代码:
UIViewController* popoverContent = [[UIViewController alloc] init];
UIView *popoverView = [[UIView alloc] init];
popoverView.backgroundColor = [UIColor whiteColor];
popoverContent.view = popoverView;
pickerPopup = [[UIPopoverController alloc] initWithContentViewController:popoverContent];
pickerPopup.delegate = (id)self;
[pickerPopup setPopoverContentSize:CGSizeMake(320, 240) animated:NO];
而且UITapGestureRecognizer
:
tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(openPicker:)];
[_form_from addGestureRecognizer:tap];