我正在尝试解雇UIPopoverController
,它正常工作。
但是,如果UIPopoverController
是根据UILongPressGestureRecognizer
操作创建的。
它不起作用。我有一个代表正在调用dismissAllPopovers
。有人有主意吗?感谢
UILongPressGestureRecognizer *longTap = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleChangeColor:)];
longTap.minimumPressDuration = 0.6;
[button addGestureRecognizer:longTap];
- (void)handleChangeColor:(UILongPressGestureRecognizer *)gesture
{
ColorPicker *colorPicker = [[ColorPicker alloc] initWithNibName:nil bundle:[NSBundle mainBundle]];
colorPicker.delegate2 = self;
colorPicker.navigationItem.title = [Language get:@"Button Color"];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:colorPicker];
self.selectColorPop = [[UIPopoverController alloc] initWithContentViewController:navController];
self.selectColorPop.popoverContentSize = CGSizeMake(300, 390);
self.selectColorPop.delegate = self;
colorPicker.myPop = self.selectColorPop;
[self.selectColorPop presentPopoverFromRect:button.frame inView:scrollView permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];
[self.selectColorPop setPassthroughViews:nil];
}
- (void) dismissAllPopOvers
{
if (self.selectColorPop != nil)
{
//[self.selectColorPop.delegate popoverControllerDidDismissPopover:self.selectColorPop];
[self.selectColorPop dismissPopoverAnimated:YES];
self.selectColorPop = nil;
}
}
答案 0 :(得分:0)
在handleChangeColor下: 我应该
if(UIGestureRecognizerStateBegan == gesture.state) {
// Called on start of gesture, do work here
[self doSomething];
}
if(UIGestureRecognizerStateChanged == gesture.state) {
// Do repeated work here (repeats continuously) while finger is down
}
if(UIGestureRecognizerStateEnded == gesture.state) {
// Do end work here when finger is lifted
}