2011-06-14 79 views
0

我使用此代码在UIViewController中显示一个项目Toolbar(由UINavigationController推送)。工具栏显示并立即消失:iPhone - UIViewController中的工具栏在显示后立即消失

UIBarButtonItem * logoutButton = [[UIBarButtonItem alloc] initWithTitle:@"Log out" style:UIBarButtonItemStylePlain target:self action:nil]; 
NSMutableArray * arr = [NSMutableArray arrayWithObjects:logoutButton, nil]; 
[self setToolbarItems:arr animated:NO]; 
[self.navigationController setToolbarHidden:NO animated:NO]; 

你知道问题是什么吗?

+1

此代码在哪里?在这里看起来并不是什么不寻常的东西,所以要么与你调用它的地方有关,要么是事后发生的其他事情(比如稍后将toolbarHidden设置为YES或其他) – 2011-06-14 14:16:29

+0

我找出问题所在。在我的应用程序中有一个地方设置工具栏隐藏UINavigationController堆栈上的所有视图控制器。 – 2011-06-20 14:16:26

+0

@Jess:你可以把你的评论作为答案,因为我想提出这个问题| ANSWERED |但不能自己做。谢谢。 – 2011-06-22 16:58:46

回答

1

这是什么代码?在这里看起来并不是什么特别的东西,所以要么与你调用它的地方有关,要么是事后发生的其他事情(例如稍后将toolbarHidden设置为YES)