我创建了一个具有视图、表格视图和文本视图的应用程序,我已经设置了我的应用程序,当用户单击按钮登录视图时,它会将他们带到表格视图并单击表格视图中的单元格将他们带到文本视图。对于所有这些,我只使用了一个 xib。一切正常。现在,当我导航到表格视图时,UIBarButton 有 3 个按钮,返回视图(左),返回表格视图(右)和一个清除按钮(右),当我单击表格视图中的一个单元格时,它会转到文本视图和所有 3 个按钮仍然存在。我需要的是当 tableview 出现时,按钮 Back to log 应该被隐藏,其他 2 应该是可见的,当我在 textview 上时,Back to main 和 Back to log 应该是可见的,并且应该隐藏清除按钮。有没有办法做到这一点?这些是我的 UIBarButtons 代码:
UIBarButtonItem *clearHistory=[[UIBarButtonItem alloc]initWithTitle:@"Clear History" style:UIBarButtonItemStyleBordered target:self action:@selector(clearTable)];
UIBarButtonItem *btnBack=[[UIBarButtonItem alloc]initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(goBack)];
self.navigationItem.leftBarButtonItem=btnBack;
UIBarButtonItem *btnBacklog=[[UIBarButtonItem alloc]initWithTitle:@"Back to log" style:UIBarButtonItemStyleBordered target:self action:@selector(goBacklog)];
self.navigationItem.rightBarButtonItems=[NSArray arrayWithObjects:clearHistory,btnBacklog, nil];
- (void)goBack {
self.tableLogView.hidden = YES;
self.navigationController.navigationBarHidden=YES;
self.viewLogToolbar.hidden=NO;
self.extendedView.hidden = YES;
}
- (void)goBacklog {
self.tableLogView.hidden = NO;
self.navigationController.navigationBarHidden=NO;
self.viewLogToolbar.hidden=YES;
self.extendedView.hidden = YES;
}
-(void)clearTable
{
if([tableData count])
{
UIAlertView *message= [[UIAlertView alloc] initWithTitle:@"Delete All History" message:@"Are you sure?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Delete", nil];
[message show];
}
else
{
UIAlertView *message= [[UIAlertView alloc] initWithTitle:@"Message" message:@"No History" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[message show];
}
}