关于弹出窗口的苹果公司的“移动人机接口指南”说:
When possible,allow people to close one popover and open a new one
with one tap. This behavior is especially desirable when several
different bar buttons each open a popover,because it prevents people
from having to make extra taps.
我现在能想到的唯一解决方案是在解除弹出窗口时跟踪触摸的位置,并检查是否是另一个按钮的位置.
有没有更简单的方法来做到这一点?
PS:我在stackoverflow中搜索并在发布之前用Google搜索了一段时间.对不起,如果之前有人问这个问题.
UPDATE
我想我没有很好地解释自己.假设我有三个按钮.所有人都打开了一个弹出窗口.我的用户点击按钮#1并打开一个弹出窗口.当弹出窗口打开时,用户点击按钮#2. popover被解雇(因为用户点击了popover之外 – 非模态弹出窗口的默认行为)并且因为用户点击了按钮#2而打开了新的弹出窗口.所有这一切都无需点击两次:一次解除弹出窗口,两次打开新弹出窗口.
第二次更新
我建造了一个简单的假人来重现我正在尝试做的事情.当用户点击按钮并打开弹出窗口时,不会调用打开弹出窗口的方法.因此,用户必须单击两次才能打开第二个弹出窗口.有任何想法吗?
#import "RootViewController.h" #import "AViewController.h" @interface RootViewController() @property (nonatomic,retain) UIPopoverController *currentPopover; @end @implementation RootViewController @synthesize currentPopover; - (void)loadView { CGRect applicationFrame = [[UIScreen mainScreen] applicationFrame]; UIView *view = [[UIView alloc] initWithFrame:applicationFrame]; CGRect buttonFrame = CGRectMake(50,100,200,40); for (int i = 0; i < 3; i++) { UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button setTitle:[Nsstring stringWithFormat:@"Button %i",i + 1] forState:UIControlStatenormal]; [button addTarget:self action:@selector(openPopover:) forControlEvents:UIControlEventTouchDown]; [button setFrame:buttonFrame]; [view addSubview:button]; buttonFrame.origin.y += 50; } self.view = view; [view release]; } - (IBAction)openPopover:(id)sender { AViewController *avc = [[AViewController alloc] init]; UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:avc]; [avc release]; UIPopoverController *tempPopover = [[UIPopoverController alloc] initWithContentViewController:navigationController]; [tempPopover setDelegate:self]; [tempPopover setPopoverContentSize:CGSizeMake(320,500)]; [tempPopover presentPopoverFromrect:[sender frame] inView:[self view] permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES]; self.currentPopover = tempPopover; [tempPopover release]; [navigationController release]; } - (void)dealloc { [currentPopover release]; [super dealloc]; } @end
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。