无法从其他视图控制器设置标签文本,或者无法将其设置为等于iOS中其他视图控制器传递的任何字符串

时间:2014-09-16 08:12:26

标签: ios ios7 uilabel

我有一个名为" lblRepeat"在名为" ScheduleEditVC"的视图控制器中。 我正在设置另一个名为" RepeatVC"的视图控制器的标签文本。使用父子关系和正常对象创建。但是不能设定价值。然后我尝试在" ScheduleEditVC"中创建一个标签。并在" RepeatVC"中设置它的值。然后使这个标签等于" lblRepeat"在" ScheduleEditVC"。但它仍然无法奏效。 以下是我的代码

第一种方式:

// directly setting the value using string.
//week is a string
scheduleView.lblRepeat.text = [NSString stringWithFormat:@"%@",week];

第二路

//using the parent child relationship
//in the ScheduleEditVC

- (IBAction)btnRepeat:(id)sender 
{
RepeatVC *repeatView1 = [[RepeatVC alloc]initWithNibName:@"RepeatVC" bundle:nil];
repeatView1.scheduleView = self;
[self.view addSubview:repeatView.view];
}
//in the RepeatVC
scheduleView.lblRepeat.text = [NSString stringWithFormat:@"%@",week];
第三种方式:

//By creating a label
//in the header of ScheduleEditVC
@property (strong,nonatomic) UILabel *txtMyRepeat;
// in RepeatVC
scheduleView.txtMyRepeat.text = [NSString stringWithFormat:@"%@",week];
//in the viewDidLoad of ScheduleEditVC.m
lblRepeat = txtMyRepeat;

所有方式都应该完美,但在这种情况下他们不会。

0 个答案:

没有答案