当没有检查单元格时,如何隐藏“下一个”barbuttonitem。但是当我检查最少 1 个单元格时,下一个按钮应该可用。
这是我的选择行:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSManagedObjectContext *context = [app managedObjectContext];
StandortCell *cell = (StandortCell *)[tableView cellForRowAtIndexPath:indexPath];
Standort *standort=[self.fetchedResultsController objectAtIndexPath:indexPath];
NSLog(@"Ausgewaehlte Standort %@",standort.ort);
if (cell.checkButton.hidden==YES){
cell.checkButton.hidden=NO;
UIBarButtonItem *myWeiter = [[UIBarButtonItem alloc] initWithTitle:@"Weiter" style:UIBarButtonItemStyleBordered target:self action:@selector(nextPressed:)];
UIBarButtonItem *myMapButton = [[UIBarButtonItem alloc]initWithTitle:@"Karte" style:UIBarButtonItemStyleBordered target:self action:@selector(mapPressed:)];
NSArray *myButtonArray = [[NSArray alloc] initWithObjects:myWeiter,myMapButton,nil];
self.navigationItem.rightBarButtonItems = myButtonArray;
}else {
cell.checkButton.hidden=YES;
self.navigationItem.rightBarButtonItem = nil;
UIBarButtonItem *myMapButton = [[UIBarButtonItem alloc]initWithTitle:@"Karte" style:UIBarButtonItemStyleBordered target:self action:@selector(mapPressed:)];
NSArray *myButtonArray = [[NSArray alloc] initWithObjects:myMapButton,nil];
self.navigationItem.rightBarButtonItems = myButtonArray;
}
if ([[standort valueForKey:@"ortcheck"] boolValue]) {
[standort setValue:[NSNumber numberWithBool:NO] forKey:@"ortcheck"];
} else {
[standort setValue:[NSNumber numberWithBool:YES] forKey:@"ortcheck"];
}
NSError *error = nil;
if (![context save:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
}
当我尝试我的代码时,nextbutton 消失,但是当我选择多个单元格并取消选择一个时,nextbutton 消失。当没有选择单元格时它应该消失