gpt4 book ai didi

iphone - 选择行时关闭弹出窗口?

转载 作者:行者123 更新时间:2023-12-03 20:53:46 25 4
gpt4 key购买 nike

当 UISPlitViewControler 处于弹出模式时从主视图中选择一行时。不是应该自动解除吗?我该如何修复它?

通常我会这样做 [self.popoverController DismissPopoverAnimated:YES]; 但在这种情况下 popoverController 无法识别。

我认为 UISplitViewController 应该自动执行此操作?

这是我的 UISplitViewDelegate 代码,位于我的DetailViewCOntroller 中:

- (void)splitViewController:(UISplitViewController *)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController: (UIPopoverController *)pc
{
barButtonItem.title = @"Medical Codes";
NSMutableArray *items = [[self.toolbar items] mutableCopy];
[items insertObject:barButtonItem atIndex:0];
[self.toolbar setItems:items animated:YES];
[items release];
}

// Called when the view is shown again in the split view, invalidating the button and popover controller.
- (void)splitViewController:(UISplitViewController *)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
NSMutableArray *items = [[self.toolbar items] mutableCopy];
[items removeObjectAtIndex:0];
[self.toolbar setItems:items animated:YES];
[items release];
}

在我的应用程序委托(delegate)中,我有:

@property (nonatomic, retain) IBOutlet UISplitViewController *splitViewController;
@property (nonatomic, retain) IBOutlet DetailViewControlleriPad *rightViewController;
@property (nonatomic, retain) IBOutlet RootViewController * leftViewController;

这些属性都连接在 IB 中。 RootViewController 推送到其他 TableView ,在弹出模式下选择它们时需要将其关闭。

编辑

- (void)setDetailItem:(id)newDetailItem
{
if (detailItem != newDetailItem)
{
[detailItem release];
detailItem = [newDetailItem retain];
[self.myTableView reloadData];
}
}

最佳答案

我总是必须手动显式关闭弹出窗口。为此,请在将弹出 View Controller 传递给我的 UISplitViewControllerDelegate 时获取对它的引用:

- (void)splitViewController:(UISplitViewController*)svc 
willHideViewController:(UIViewController *)aViewController
withBarButtonItem:(UIBarButtonItem*)barButtonItem
forPopoverController:(UIPopoverController*)pc
{
splitViewPopover = [pc retain];
// Other stuff
}

因为我这样做,所以当引用不再有效时,我还必须释放该引用:

- (void)splitViewController:(UISplitViewController*)svc 
willShowViewController:(UIViewController *)aViewController
invalidatingBarButtonItem:(UIBarButtonItem *)button
{
[splitViewPopover release];
splitViewPopover = nil;
// Other stuff
}

然后,当在我的主视图 Controller 中选择一个项目时,我会更新我的详细信息 Controller 并关闭弹出窗口:

[splitViewPopover dismissPopoverAnimated:NO];

关于iphone - 选择行时关闭弹出窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7155313/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com