更好的方法是在AddTaskViewController
上创建NSString*
属性。你可以这样说:
在AddTaskViewController.h
添加以下内容:
@property (nonatomic, strong) NSString* myLabelsText;
然后在AddTaskViewController.m
一定要添加这个在viewWillAppear
:
self.testlabel.text = self.myLabelsText;
现在假设你已经声明了testLabel
和myLabelsText
适当,他们得到合成,你的视图控制器将在适当的时间正确应用字符串,然后你的功能应该改为:
- (IBAction)donebutton:(id)sender {
AddTaskViewController *addtask = [[AddTaskViewController alloc]initWithNibName:@"AddTask" bundle:nil];
// Set the value on your new NSString* property and let the view controller handle the rest
addTask.myLabelsText = self.zaman1.text;
// Don't you want to 'present' the view controller rather than 'dismiss' after having provided it with data?
[self dismissViewControllerAnimated:YES completion:nil];
}
你期望发生的?在您创建视图控制器的那一刻,然后对它完全没有任何影响。你是否想要'presentViewController:...'? – Tommy 2013-04-23 23:37:12
我想等于label.text – Salieh 2013-04-23 23:42:36
@Salieh:Tommy说得对,可能是你用'presentViewController'混淆了它。你究竟想达到什么目的,你能否详细说明一下? – 2013-04-24 00:01:44