帮助导航控制器、窗口和子视图!
我的第一个 xib 在 MainWindow.xib 中包含一个带有类似跳板的界面的 ScrollView:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
navController = [[UINavigationController alloc] init];
[navController setNavigationBarHidden:YES]; [窗口addSubview:navController.view]; [窗口 sendSubviewToBack:navController.view];当
单击按钮时,FirstViewController 会显示一个表格视图和一个导航控制器:
- (void) buttonPushed:(id)sender {
FirstViewController *firstViewController = [[FirstViewController alloc] init];
[navController pushViewController:firstViewController animated:YES];
[firstViewController release];
[window addSubview:navController.view]; }
当我单击导航控制器中的后退按钮返回跳板时,我得到了跳板 xib,但对顶部导航栏的触摸没有响应!
- (void)goHome:(id) sender {
[self.view removeFromSuperview];
如何在不将导航栏堆叠在顶部的情况下返回跳板屏幕(mainwindow.xib)并响应触摸?
my first xib contains a ScrollView with a springboard like interface in MainWindow.xib:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
navController = [[UINavigationController alloc] init];
[navController setNavigationBarHidden:YES];
[window addSubview:navController.view];
[window sendSubviewToBack:navController.view]; }
When a button is clicked the FirstViewController appears with a tableview and a navigation controller:
- (void) buttonPushed:(id)sender {
FirstViewController *firstViewController = [[FirstViewController alloc] init];
[navController pushViewController:firstViewController animated:YES];
[firstViewController release];
[window addSubview:navController.view]; }
When I click the back button in Navigation Controller to go back to springboard, I get the springboard xib, but unresponsive to touches with a Navigation Bar on top!
- (void)goHome:(id) sender {
[self.view removeFromSuperview];
How can I go back to springboard screen (mainwindow.xib) without having the navigation bar stacked on top, and be responsive to touches ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为什么不将跳板视图设置为导航控制器的根视图控制器并删除窗口中的任何 UI?
我认为窗口不应该有任何 UI 元素接受添加到其中的视图控制器的视图(通过导航控制器或选项卡栏控制器)。
这样,您就不必重新发明轮子来从跳板视图加载第一个视图,并且后退按钮将正常工作。
您可以在根视图控制器(跳板视图的视图控制器)的viewDidLoad方法中将navigationBarHidden属性设置为false。
Why don't you set the springboard view to be the root view controller of your navigation controller and get rid of any UI in the window?
I think that the window shouldn't have any UI elements accept view of view controllers that are added to it (by navigation controller or by tab bar controller).
This way you won't have to reinvent the wheel for the first view to load from the springboard view and the back button will work properly.
You can set the navigationBarHidden property to false in the viewDidLoad method of the root view controller (the view controller of the springboard view).
您是否尝试调用 [navController setNavigationBarHidden:YES];在你的主视图 viewWillAppear 回调中?
Did you try calling [navController setNavigationBarHidden:YES]; in your mainview viewWillAppear callback ?
{
}
{
}