为什么设置导航栏颜色会导致Xcode崩溃?

时间:2014-11-18 13:50:57

标签: ios objective-c xcode

我将下面的代码添加到NavigationController.m,但是当我尝试在模拟器中运行应用程序时,它会崩溃Xcode。这段代码有什么问题?

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.view addGestureRecognizer:[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureRecognized:)]];

    if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
        // iOS 6.1 or earlier
        self.navigationController.navigationBar.tintColor = [UIColor redColor];
    } else {
        // iOS 7.0 or later
        self.navigationController.navigationBar.barTintColor = [UIColor redColor];
        self.navigationController.navigationBar.translucent = NO;
    }

}

0 个答案:

没有答案