ios - 在 iOS 中单击按钮时显示空白屏幕

标签 ios xcode xcode6.3

我在主屏幕中添加了一个 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/

相关文章:

ios - Swift 1.2 (Xcode 6.3) 删除了 Bool 值的 xor '^' 运算符?

swift - SCNIKConstraint 如何工作?

ios - 在设备上部署和测试应用程序

iphone - Apple/iPhone 开发 IDE 首选项?

ios - 我怎样才能让背景不覆盖每个按钮、标签?

ios - Xcode 6.3 : Comparison of address of 'UIApplicationOpenSettingsURLString' not equal to a null pointer is always true 打开设置警告问题

iOS 归档时发现意外的 Mach-O header 代码 : 1918975009

iphone - 允许对象类型为 'id' 还是为方法的两种不同类型提供两个参数更好?

ios - MagicalRecord 在 ios8 上崩溃

ios - jQuery Mobile 和 PhoneGap : body background during transition