-2

DidSelectRowAtIndexそのため、TableView.m でボタンを非表示にしようとしており、2 行目に等しい選択を行うたびに、ViewController.h でボタンが宣言されます。

私のコード:

TableView.m:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    [popoverSpending dismissPopoverAnimated:YES];

    UITableViewCell *cell = (UITableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
    if([self.delegate respondsToSelector:@selector(spendingButtonText:)]) {
        [self.delegate spendingButtonText:cell.textLabel.text];
    }

    if (indexPath.row == 2) {
        NSLog(@"2");
        AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; 
        appDelegate.vc=[[ViewController alloc] init];

        appDelegate.vc.button1.hidden = TRUE;

    }

    [self dismissViewControllerAnimated:YES completion:nil];
}

2 番目の行を選択すると、トレース 2 が表示されます。これは の正当な原因ですNSLog(@"2");。ただし、button1という名前のボタンはまだ表示されています。私の TableView.m は ViewController のクラスです。もっと多くのコードや不適切な編集が必要な場合は教えてください。

4

1 に答える 1