0
두 개의 viewCOntroller가 있습니다. 첫 번째에는 단추가 있으며, 눌렀을 때 다른 viewcontroller에 tableview가 포함되어 있습니다. 선택한 tableView 셀은 첫 번째 viewController의 단추에 대한 새 제목이어야합니다.UIButton IBOutlet을 프로그래밍 방식으로 변경
제의 ViewController .H
@property (weak, nonatomic) IBOutlet UIButton *btn1Out;
- (IBAction)btn1:(id)sender;
제의 ViewController하는 .m
- (IBAction)btn1:(id)sender
{
viewcontroller2 = [[PopUpViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewcontroller2];
[self.navigationController presentViewController:navController animated:YES completion:nil];
}
의 ViewController 2 .H
@property (nonatomic, retain) UITableView *tableView;
@property (nonatomic, retain) NSString *currentStartStation;
의 ViewController 2하는 .m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
self.selectedCell = [NSString stringWithFormat:@"Cell %d", indexPath.row+1];
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
NewViewController *firstViewControllerObj = [[NewViewController alloc] init];
[firstViewControllerObj.btn1Out setTitle:[NSString stringWithFormat:@"%@", self.selectedCell] forState:UIControlStateNormal];
}
viewController2가 닫히면 버튼 제목이 변경되지 않습니다. 뭐가 문제 야?
위임자를 설정해야합니다. –