我在视图中遇到条形按钮项目时遇到了问题。我有一个子视图,被添加到超级视图,当我点击barbuttonitem它崩溃的应用程序,我得到这个错误
*** -[DetailViewController performSelector:withObject:withObject:]: message sent to deallocated instance 0x27677fa0
- (void)viewDidLoad
{
[super viewDidLoad];
navBar.tintColor = [UIColor blackColor];
UIColor *topGreen = [UIColor colorWithRed:246/255.f green:241/255.f blue:206/255.f alpha:1];
UIColor *bottomGreen = [UIColor colorWithRed:242/255.f green:237/255.f blue:204/255.f alpha:1];
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = self.view.bounds;
gradient.colors = [NSArray arrayWithObjects:(id)topGreen.CGColor, (id)bottomGreen.CGColor, nil];
[self.view.layer insertSublayer:gradient atIndex:0];
backButton = [[UIBarButtonItem alloc] initWithTitle:@"Map" style:UIBarButtonSystemItemAction target:self action:@selector(returnToMap:)];
UINavigationItem *navButton = [[UINavigationItem alloc]init];
navButton.leftBarButtonItem = backButton;
[navBar pushNavigationItem:navButton animated:YES];
navBar.topItem.title = title;
NSLog(@"Reached");
//[self returnToMap];
//Do any additional setup after loading the view from its nib.
}
我不知道如何解决这个问题。我已经尝试添加barbutton作为属性并合成它但似乎没有任何效果。任何帮助都会很棒
答案 0 :(得分:0)
问题不在UIBarButtonItem
,而在DetailViewController
实例中 - 您过早发布,或者没有保留参考。