UIBarButtonItem不会显示

时间:2012-10-29 19:48:09

标签: iphone objective-c ios

为什么不显示?我试过模拟器5.1和6.0。最近发生了什么变化?

UIBarButtonItem* rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPageCurl target:self action:@selector(openGasMileage)];

self.navigationItem.rightBarButtonItem = rightBarButtonItem;

1 个答案:

答案 0 :(得分:1)

由于> = ios5 sdk中不存在默认卷曲图像,您必须使用自己的图像:

- (UIBarButtonItem *) rightBarButtonItem {
    if (_rightBarButtonItem == nil) {
    UIButton *rightButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
    [rightButton setImage:[UIImage imageNamed:@"edit.png"] forState:UIControlStateNormal];
    [rightButton addTarget:self action:@selector(own) forControlEvents:UIControlEventTouchUpInside];
    _rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
    }
return _rightBarButtonItem;
}

self.navigationItem.rightBarButtonItem = self.rightBarButtonItem;

另见:curl item