我正在开发一个标签栏应用程序。
TAB-BAR CONTROLLER
|
_______________________________________________________
| | | |
View 1 View 2 View 3 View 4
| |
SearchingON Detail View
问题 1:我有一个按钮(比如注销),单击 View 4 上的按钮时,我想弹出 View 2 的详细 View 。
这样新用户在新登录后就不会看到详细信息了。
我试过了:
if ([[NSUserDefaults standardUserDefaults] valueForKey:@"IsChattingON"])
{
ChatDetail *chat = [[ChatDetail alloc] initWithNibName:@"ChatDetail" bundle:nil];
[chat BackButtonClicked:nil];
}
在详细 View 返回按钮中,我的代码是:
-(IBAction)BackButtonClicked:(id)sender
{
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"IsChattingON"];
[self.navigationController popViewControllerAnimated:YES];
}
无论 Detail View 是否打开,这里的 User Defaults 都具有 Bool 值。
问题 2:我在 View 1 的 TableView 上应用搜索,如果单击 View 4 的注销按钮,我想删除搜索。如果单击 View 4 的注销按钮,我想刷新我的 View 1。
为了删除搜索,我已经完成了这段代码,但没有得到想要的结果。
PeopleController *People = [[PeopleController alloc] initWithNibName:@"PeopleController" bundle:nil];
People.isSearchingRecords = NO;
到目前为止,我已经搜索过有关 popViewControllers 的内容,但找不到这个场景。请告诉我如何实现此功能。
最佳答案
当用户点击注销时,你不应该分配一个新的 View Controller , 相反,您应该执行以下操作
- (void) logOut
{
//get the view 2
//you should have a way to access view 2
[view2 closeChatView];
}
//On view 2 maintain a reference of chat detail controller
- (void) closeChatView
{
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"IsChattingON"];
//chat is the reference to the chat details controller
[chat.navigationController popViewControllerAnimated:YES];
}
关于iphone - Tabbar 应用程序中的 PopViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10845371/