我有一个带有viewController
的{{1}}和带有textView
的secondviewController我试图将textView中的文本传递给标签
首先
label
//更改视图并将textview发送到标签
.m
textView= [[UITextView alloc] initwithFrame...
//附在nib上
-(void) gotoSecond:(id) sender{
Second *sec = [[Second alloc]initWithNibName: @"Second" bundle:nil];
[sec.note setText:textView.text]
[self presentViewController:sec animated: YES completion:NULL];
}
Second .h
答案 0 :(得分:0)
使用此:
在viewController.m中
-(void) gotoSecond{
secondViewController *sec = [[secondViewController alloc]initWithNibName: @"Second" bundle:nil];
[sec.passedText setText:textView.text]
[self presentViewController:sec animated: YES completion:NULL];
}
在secondViewController.h中
@property(nonatomic, strong)NSString *passedText;
在secondViewController.m
中-(void)viewDidLoad
{
self.note.text = passedText;
}
答案 1 :(得分:0)
使用此:
-(void) gotoSecond:(id) sender{
Second *sec = [[Second alloc]initWithNibName: @"Second" bundle:nil];
[self presentViewController:sec animated: YES completion:^(){
[sec.note setText:textView.text];
}];
}