You can simply ask the alert view for its title
, and pass that to the next view controller. In the next view controller's viewDidLoad
, it can put the title in the text field.
// In the view controller responsible for the alert view:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
NextViewController *vc = [[NextViewController alloc] init];
vc.titleForTextField = alertView.title;
[self presentViewController:vc animated:YES completion:nil];
}
// In NextViewController:
- (void)viewDidLoad {
[super viewDidLoad];
self.textField.text = self.titleForTextField;
}
(You'll need to give NextViewController
a titleForTextField
property.)