0

我有一个viewController带有 atextView和一个带有 a 的 secondviewControllerlabel我正在尝试将 textView 中的文本传递给标签

第一的

.m

textView= [[UITextView alloc] initwithFrame...

//更改视图并将文本视图发送到标签

-(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

//附在笔尖上

@propery (nonatomic, strong) IBOutlet UILabel *note; 
4

2 回答 2

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;
}
于 2013-08-19T13:02:33.600 回答
0

用这个:

-(void) gotoSecond:(id) sender{
    Second *sec = [[Second alloc]initWithNibName: @"Second" bundle:nil];
    [self presentViewController:sec animated: YES completion:^(){
         [sec.note setText:textView.text];
    }]; 
}
于 2013-08-19T14:36:14.907 回答