我是新手在ios .I中有一个导航栏,其中包含多个按钮,包括后退按钮,排序,过滤器,设置按钮和一个打开弹出窗口的按钮。当从UINavigationController中的navigationItem打开时,UIPopoverController不会被关闭。
当我点击过滤器导航项目popoverView控制器工作正常,但问题是,如果我点击其他导航项目,如后退,排序,设置不是dismissing.when我点击或触摸导航栏弹出没有解除如何纠正这个问题?
viewController.h
IBOutlet UINavigationBar *navigationBar;viewController.m
UIBarButtonItem *leftButton = [UIBarButtonItem barItemWithImage:[UIImage imageNamed:@"back_btn.png"] target:self action:@selector(onBack)];
UINavigationItem *item = [[UINavigationItem alloc] initWithTitle:@""];
UIButton *btnMainLogo = [UIButton buttonWithType:UIButtonTypeCustom];
[btnMainLogo setImage:[UIImage imageNamed:@"dina_new_logo.png"] forState:UIControlStateNormal];
btnMainLogo.frame = CGRectMake(0, 0, 160, 36);
[btnMainLogo addTarget:self action:@selector(onHome) forControlEvents:UIControlEventTouchUpInside];
item.titleView = btnMainLogo;
item.leftBarButtonItem = leftButton;
item.hidesBackButton = YES;
//RIGHT MENU
NSMutableArray *arrRightBarItems = [[NSMutableArray alloc] init];
UIButton *btnSetting = [UIButton buttonWithType:UIButtonTypeCustom];
[btnSetting setImage:[UIImage imageNamed:@"settings.png"] forState:UIControlStateNormal];
btnSetting.frame = CGRectMake(0, 0, 32, 32);
btnSetting.showsTouchWhenHighlighted=YES;
[btnSetting addTarget:self action:@selector(onSettings:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btnSetting];
UIButton *btnShare = [UIButton buttonWithType:UIButtonTypeCustom];
[btnShare setImage:[UIImage imageNamed:@"share-icon.png"] forState:UIControlStateNormal];
btnShare.frame = CGRectMake(0, 0, 32, 32);
btnShare.showsTouchWhenHighlighted=YES;
[btnShare addTarget:self action:@selector(onShare:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *barButtonItem1 = [[UIBarButtonItem alloc] initWithCustomView:btnShare];
UIBarButtonItem *edit = [[UIBarButtonItem alloc]
initWithTitle:@"Edit"
style:UIBarButtonItemStylePlain
target:self
action:@selector(onEditIssue:)];
UIBarButtonItem *sortByDate = [[UIBarButtonItem alloc]
initWithTitle:@"Sort"
style:UIBarButtonItemStylePlain
target:self
action:@selector(onSortByDate:)];
UIBarButtonItem *FilterByIssue = [[UIBarButtonItem alloc]
initWithTitle:@"Filter"
style:UIBarButtonItemStylePlain
target:self
action:@selector(onFilterByIssue:)];
NSArray *arrBtns = [[NSArray alloc]initWithObjects:barButtonItem,barButtonItem1,edit,sortByDate,FilterByIssue, nil];
[arrRightBarItems addObjectsFromArray:arrBtns];
[item setRightBarButtonItems:arrRightBarItems];
[navigationBar pushNavigationItem:item animated:NO];发布于 2013-03-14 22:08:23
尝试在每个栏按钮项的回调中取消弹出。例如:
-(void)onEditIssue:(id)sender
{
if ([popoverController isPopoverVisible])
[popoverController dismissPopoverAnimated:YES];
//Do other stuff
}发布于 2014-03-14 07:35:26
This answer的被接受的答案对我很有效。将popover控制器的passthroughViews设置为nil。
https://stackoverflow.com/questions/15410419
复制相似问题