我在主屏幕中添加了一个 UIBarButtonItem 并为其创建了一个 b.xib、b.h 和 b.m 文件。当我点击按钮时,它应该打开相关屏幕,但它没有打开,而是打开空白屏幕。
我是 iOS 编程的新手....
下面是 A.m
文件中的代码,我在其中添加了按钮,当点击它时它应该打开 b.xib
。
UIBarButtonItem *bButton = [[UIBarButtonItem alloc]
initWithTitle:@"B"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(openB:)];
self.navigationItem.leftBarButtonItem = bButton;
bButton.TintColor = [UIColor colorWithRed:0.0 green:0.31 blue:0.56 alpha:1.0];
[bButton release];
- (void)openB:(id)sender {
BViewController *b = [[BViewController alloc] init];
// ttod.defViewC = self; //Bookmarks from the definition view
[self presentModalViewController:b animated:YES];
[b release];
}
任何想法......我怎样才能让它完美地工作......
最佳答案
BViewController *b = [[BViewController alloc] init];
如果您为 ViewController 创建一个 nib,您应该改用 initWithNibName:bundle:
。
关于ios - 在 iOS 中单击按钮时显示空白屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30933184/