无法在 UINavigationBar 上拖动导航项
Can't drag navigation item on UINavigationBar
我无法将导航项拖到我的 UINavigationBar
上。它只允许我拖动一个条形按钮项目。有没有办法以编程方式添加后退按钮?谢谢
添加按钮很简单
UIBarButtonItem *barBtn = [[UIBarButtonItem alloc]init];
self.navigationItem.leftBarButtonItem=barBtn;
更改标题和属性只需使用
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:self.navigationItem.backBarButtonItem.style target:nil action:nil];
在 viewDidLoad 中添加这个
UIBarButtonItem *backButton = [[UIBarButtonItem alloc]initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(backAction:)];
self.navigationItem.leftBarButtonItem = backButton;
并实施 backAction,
-(void)backAction
{
[self.navigationController popViewControllerAnimated:YES];
}
我无法将导航项拖到我的 UINavigationBar
上。它只允许我拖动一个条形按钮项目。有没有办法以编程方式添加后退按钮?谢谢
添加按钮很简单
UIBarButtonItem *barBtn = [[UIBarButtonItem alloc]init];
self.navigationItem.leftBarButtonItem=barBtn;
更改标题和属性只需使用
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:self.navigationItem.backBarButtonItem.style target:nil action:nil];
在 viewDidLoad 中添加这个
UIBarButtonItem *backButton = [[UIBarButtonItem alloc]initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(backAction:)];
self.navigationItem.leftBarButtonItem = backButton;
并实施 backAction,
-(void)backAction
{
[self.navigationController popViewControllerAnimated:YES];
}