苹果公司的“移动人机界面指南”对 Popover 的描述如下:
如果可能,允许人们关闭一个弹出窗口并打开一个新弹出窗口
只需轻轻一按。当有多个
不同的栏按钮每个都会打开一个弹出窗口,因为它阻止人们
无需进行额外的点击。
我现在能想到的唯一解决方案是在关闭弹出窗口时跟踪触摸的位置,并检查这是否是另一个按钮的位置。
有没有更简单的方法来做到这一点?
PS:我在 stackoverflow 上搜索并在发布之前用 google 搜索了很长一段时间。抱歉,如果之前有人问过这个问题。
UPDATE
我想我没有很好地解释自己。假设我有三个按钮。他们所有人都打开一个弹出窗口。我的用户点击按钮 #1 并打开一个弹出窗口。当弹出窗口打开时,用户点击按钮#2。弹出窗口被关闭(因为用户点击了弹出窗口的外部 - 非模态弹出窗口的默认行为),并且由于用户单击了按钮 #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
如果您在工具栏中使用栏按钮项目,则打开的弹出窗口是not当您点击另一个栏按钮项目时自动关闭。在这些情况下,您应该关闭可见的弹出窗口并一步打开另一个弹出窗口。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)