今天在网上搜了好多解决方案,一直没有解决这个问题,按理说将leftBarButtonItem置为nil就可以了,但是问题依然存在
- (void)viewDidLoad {
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = NO;
// Register cell classes
[self.collectionView registerNib:[UINib nibWithNibName:@"MovieCollectionViewCell" bundle:nil]
forCellWithReuseIdentifier:reuseIdentifier];
self.collectionView.backgroundColor = [UIColor whiteColor];
// 删除导航栏左侧按钮
self.navigationItem.leftBarButtonItem = nil;
// 导航栏添加右侧按钮
self.navigationItem.rightBarButtonItem = ({
UIBarButtonItem *rightBtn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"btn_nav_list.png"]
style:UIBarButtonItemStyleDone target:self action:@selector(backButtonAction:)];
rightBtn;
});
// 加载数据
[self loadData];
}
包括
self.navigationItem.leftBarButtonItem = [UIBarButtonItem new];
同样没有效果。
迫不得已,我新建了一个UIBarButtonItem对象,将它的title属性设为空,问题解决了
// 删除导航栏左侧按钮
UIBarButtonItem *barBtn = [[UIBarButtonItem alloc]init];
barBtn.title=@"";
self.navigationItem.leftBarButtonItem = barBtn;</span>
另一种解决方法:
self.navigationItem.hidesBackButton = YES;