0
我在我的表視圖控制器中有這個,我想將單元格的文本值傳遞給我在模態視圖上的UITextField。將文本值從一個視圖傳遞到另一個視圖
- (void)buttonTapped:(id)sender {
AddName *addName = [[AddName alloc] init];
UITableViewCell *cell = (UITableViewCell*)[sender superview];
NSLog(@"text in buttontapped: %@", cell.textLabel.text);
addName.nameField.text = cell.textLabel.text;
addName.delegate = self;
[self presentModalViewController:addName animated:YES];
}
NSLog顯示正確的單元格文本值。
在我的模式視圖的viewDidLoad方法我有這個...和文本值永遠不會被設置...
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"text: %@",nameField.text);
nameField.autocapitalizationType = UITextAutocapitalizationTypeWords;
nameField.autocorrectionType = UITextAutocorrectionTypeDefault;
[nameField becomeFirstResponder];
}
這是怎麼回事?
謝謝。