将textView传递给标签-iphone

时间:2013-08-19 12:54:06

标签: objective-c

我有一个带有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

2 个答案:

答案 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];
    }]; 
}