我想在导航栏中的后退按钮右侧有一个uibarbuttonitem(如果苹果指南行没有错误)。我使用这段代码:
UIBarButtonItem listButton = new UIBarButtonItem ("List View",UIBarButtonItemStyle.Bordered ,null);
//assigning left bar buttons
this.NavigationItem .LeftBarButtonItems =
new UIBarButtonItem[] { this.NavigationItem .BackBarButtonItem ,listButton } ;
但this.NavigationItem .BackBarButtonItem
始终为空。什么解决方案适合这个目的?
答案 0 :(得分:0)
这是正确的实现方式:
UIButton *leftButtonIcon = [[UIButton alloc] initWithFrame:CGRectMake(0.0f, 0.0f, width, height)];
[leftButtonIcon setImage:[UIImage imageNamed:@"yourButtonImageName.png"] forState:UIControlStateNormal];
[leftButtonIcon addTarget:self.viewDeckController action:@selector(YourSelectorMethod) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *leftbtn = [[UIBarButtonItem alloc] initWithCustomView:leftButtonIcon];
[self.navigationItem setLeftBarButtonItem:leftbtn];