Iphone 工具栏未使用视图推送的项目
我有一个基于NavigationController的iPhone应用程序,它有一个navigationBar和一个工具栏。下面是它的基本工作原理: ApplicationLegate将“SplashScreen”作为模式视图推送到RootViewController上。当启动屏幕打开时,应用程序会执行一些工作,并且基于用户的位置,它会关闭模式视图,或者关闭模式视图并将另一个视图推到导航堆栈上 RootViewController和子视图都有带有添加按钮的工具栏。我的问题是:当自动按下第二个视图时,Add按钮调用其父控制器的代码。如果您取消此操作,然后再次按add按钮,则会调用正确的代码 这是我的一些代码 在RootViewController的viewDidLoad中,我有:Iphone 工具栏未使用视图推送的项目,iphone,uiviewcontroller,uinavigationcontroller,uitoolbar,Iphone,Uiviewcontroller,Uinavigationcontroller,Uitoolbar,我有一个基于NavigationController的iPhone应用程序,它有一个navigationBar和一个工具栏。下面是它的基本工作原理: ApplicationLegate将“SplashScreen”作为模式视图推送到RootViewController上。当启动屏幕打开时,应用程序会执行一些工作,并且基于用户的位置,它会关闭模式视图,或者关闭模式视图并将另一个视图推到导航堆栈上 RootViewController和子视图都有带有添加按钮的工具栏。我的问题是:当自动按下第二个视图
addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addClicked:)];
[self setToolbarItems:[NSArray arrayWithObjects:addButton, nil]];
addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addClicked:)];
[self setToolbarItems:[NSArray arrayWithObjects:addButton, nil]];
在子控制器(LocationListsController)的viewDidLoad中,我有:
(是相同的代码,它们都有addClicked事件)
在RootViewController中,ViewWillDisplay是我实际推送子视图的位置:
if (((GeoListsAppDelegate *)[[UIApplication sharedApplication] delegate]).selectedIndex != -1)
{
GeoLocation *location = [((GeoListsAppDelegate *)[[UIApplication sharedApplication] delegate]).locations objectAtIndex:((GeoListsAppDelegate *)[[UIApplication sharedApplication] delegate]).selectedIndex];
((GeoListsAppDelegate *)[[UIApplication sharedApplication] delegate]).selectedIndex = -1;
if (lController == nil)
{
LocationListsController *aController = [[LocationListsController alloc] initWithLocation:location];
self.lController = aController;
[aController release];
}
[[self navigationController] pushViewController:lController animated:YES];
}
视图的推送效果很好。我唯一的问题是工具栏上的addButton。有人有什么想法吗?尝试从ViewDidDisplay而不是ViewWillDisplay中推送“子”视图控制器。应该注意,我没有在这里显示模式视图的推送,但我尝试摆脱它,但它什么也没做。所以模态视图真的不相关。我发誓我已经试过了,但我只是进去再做一次,结果成功了!谢谢