如何在 uisplitviewcontroller 中关闭 NavigationController 后重新加载 tableView?

发布于 2024-12-02 16:39:03 字数 812 浏览 1 评论 0原文

我使用 UISplitviewController 作为模板。

编辑按钮的操作:

newExViewController *editWindow =[[newExViewController alloc]initWithNibName:@"newExViewController" bundle:nil];
UINavigationController *navBar=[[UINavigationController alloc]initWithRootViewController:editWindow];
navBar.modalPresentationStyle = UIModalPresentationFormSheet;
navBar.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

[self presentModalViewController:navBar animated:YES];
[navBar release];

[editWindow release];

navBar 有一个用于 saveButton 的 UIBarButton。 现在,当您按下 SaveButton 时会调用此方法,这

[self dismissModalViewControllerAnimated:YES];

就是问题所在: 知道如何在 modalView 关闭时重新加载主 NavigationConteroller 和DetailViewController 的数据吗? 我不知道 谢谢

I'm using a UISplitviewController as a template.

action for edit button:

newExViewController *editWindow =[[newExViewController alloc]initWithNibName:@"newExViewController" bundle:nil];
UINavigationController *navBar=[[UINavigationController alloc]initWithRootViewController:editWindow];
navBar.modalPresentationStyle = UIModalPresentationFormSheet;
navBar.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

[self presentModalViewController:navBar animated:YES];
[navBar release];

[editWindow release];

navBar has a UIBarButton for saveButton. This is called when you press SaveButton

[self dismissModalViewControllerAnimated:YES];

now is the problem:
any idea how to reload the data for both the main NavigationConteroller and the detailViewController when the modalView is dismissed??
I have no clue
thnx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

娇柔作态 2024-12-09 16:39:03

您应该查看 NSNotificationCenter。在您的 UITableView 视图中,创建通知侦听器。然后在关闭的视图中调用该通知。

更具体地说,通知将调用一个应包含 reloadData 的方法。

示例

以下内容应与您要重新加载的 UITableView 一起使用:

这可以与您的 [selfmissModalViewControllerAnimated:YES]; 一起使用,

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(someMethodToReloadTable) name:@"reloadTable" object:nil];

这是您调用通知中心来重新加载表格的方式:

[[NSNotificationCenter defaultCenter] postNotificationName:@"reloadTable" object:self];

示例通知方法:

- (void)someMethodToReloadTable:(NSNotification *)notification 
{
    [myTableView reloadData];  
}

并且不要忘记删除通知观察者:

-(void)viewDidUnload 
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"reloadTable" object:nil];
}

You should look into NSNotificationCenter. In your view with the UITableView, create the notification listener. Then in the view that dismisses, call that notification.

To be more specific, the Notification will call a method that should contain reloadData.

Example

The following should go with the UITableView you want to reload:

This could go along with your [self dismissModalViewControllerAnimated:YES];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(someMethodToReloadTable) name:@"reloadTable" object:nil];

This is how you will call the notification center to reload the table:

[[NSNotificationCenter defaultCenter] postNotificationName:@"reloadTable" object:self];

Example of the notification method:

- (void)someMethodToReloadTable:(NSNotification *)notification 
{
    [myTableView reloadData];  
}

And don't forget to remove the notificaiton observer:

-(void)viewDidUnload 
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"reloadTable" object:nil];
}
几度春秋 2024-12-09 16:39:03

在包含要重新加载的视图的控制器中,您应该拒绝以下方法,该方法将在 modalView 被关闭时(或首次加载控制器的主视图时)被调用:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    // here you can reload needful views, for example, tableView:
    [tableView reloadData];
}  

In controllers, that contains view you want to reload, you should decline following method which will be called when the modalView will be dismissed (or when controller's main view will be first time loaded):

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    // here you can reload needful views, for example, tableView:
    [tableView reloadData];
}  
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文