我正在尝试使用这种架构开发一个应用程序(游戏):
- 主视图是基于隐藏导航栏的导航控制器
- 在主视图中,我需要一个灯光信息按钮来显示选项/信用翻转视图
- 这个翻转视图必须有另一个带有右栏按钮到“完成”系统按钮的navigationcotroller
问题是flipsideview没有显示完成按钮,它似乎显示了主导航控制器......
这是代码。
应用委托:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
主视图(从 XIB 加载)。仅提取 showInfo:
-(IBAction) showInfo:(id)sender {
FlipSideViewController *controller = [[FlipSideViewController alloc] initWithNibName:@"FlipSideView" bundle:nil];
controller.delegate = self;
controller.title = @"Info";
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller];
navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
navController.navigationBar.barStyle = UIBarStyleBlackOpaque;
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonItemStyleDone
target:controller action:@selector(done:)];
navController.navigationItem.rightBarButtonItem = doneButton;
controller.navController = navController;
[self presentModalViewController:navController animated:YES];
[doneButton release];
[controller release];
[navController release];
}
- (void)flipsideViewControllerDidFinish:(FlipSideViewController *)controller {
[self dismissModalViewControllerAnimated:YES];
}
翻转侧视图。在 XIB 中,我只有一个空白视图,其插座链接到 UIViewController 视图。
@protocol FlipsideViewControllerDelegate;
@interface FlipSideViewController : UIViewController {
id <FlipsideViewControllerDelegate> delegate;
UINavigationController *navController;
}
@property (nonatomic,assign) id <FlipsideViewControllerDelegate> delegate;
@property (nonatomic,retain) UINavigationController *navController;
-(IBAction)done;
@end
@protocol FlipsideViewControllerDelegate
- (void)flipsideViewControllerDidFinish:(FlipSideViewController *)controller;
@end
}
执行文件...
- (void)viewDidLoad
{
[super viewDidLoad];
self.navController.navigationItem.title = @"Pippo";
}
#pragma mark - User Methods
- (IBAction)done {
[self.delegate flipsideViewControllerDidFinish:self];
}
结果是:
- 显示没有导航栏的主视图
- 点击信息按钮
- Flipsideview 显示动画和导航栏,标题为“信息”而不是“pippo”而不是右侧的“完成”按钮...
我哪里错了??