我想玩UIPopupController,並且我明白我無法檢測到我的popover關閉時。 我的步驟:
1.創建例如在Xcode(文件 - >新建項目 - > Utilitiy應用)
2.添加到MainViewController.h UIPopoverControllerDelegate
檢測popover關閉
#import "FlipsideViewController.h"
@interface MainViewController : UIViewController <FlipsideViewControllerDelegate,UIPopoverControllerDelegate>
@property (strong, nonatomic) UIPopoverController *flipsidePopoverController;
- (IBAction)showInfo:(id)sender;
@end
- 在MainViewController:
- (IBAction)showInfo:(id)sender { if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideViewController" bundle:nil]; controller.delegate = self; controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self presentModalViewController:controller animated:YES]; } else { if (!self.flipsidePopoverController) { FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideViewController" bundle:nil]; controller.delegate = self; self.flipsidePopoverController.delegate = self self.flipsidePopoverController = [[UIPopoverController alloc] initWithContentViewController:controller]; } if ([self.flipsidePopoverController isPopoverVisible]) { [self.flipsidePopoverController dismissPopoverAnimated:YES]; } else { [self.flipsidePopoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; } } } -(void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController { NSLog(@"OLOLO"); }
但是當我點擊某處並且popover消失時,控制檯中沒有NSLog消息。 我在做什麼錯?
要設置委託* *之前**你實例化popover控制器。換句話說,當您設置代表 – 2012-04-25 21:47:06
真相,真相時,它不存在。非常感謝! – 2012-04-26 08:45:47