0
セルがチェックされていないときにどうすれば 'next'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が消えるが、私は複数のセルを選択して、1の選択を解除したときに、nextbuttonが消える:
は、ここに私のdidselectedrowです。ビューが構築されるときにセルが
いくつかのセルを選択すると再び選択解除され、ボタンは再び非表示になりませんでした。( –
)このメソッドは行が選択されたときにのみ呼び出されるためです。今追加するメソッドを使用します。 – Manuel
あなたは私の質問を理解していないと思います。ビューが開いているときに、次のボタンが非表示になります。最小1個のセルをタップすると、チェックマークが表示され、次のボタンが表示されます。選択したセルをすべて選択解除すると、チェックマークは消えますが、次のボタンは引き続き表示されます –