In my viewcontroller,
I am creating a label here.
In another viewcontroller I am creating an instance of the first view controller. Here I tried setting the text property of the label. But it doesn't work. I have checked my code over and over and couldn't find any anything missing.
I tried creating the label both programmatically as well as using interface builder. Still cant set the text property of the label. Any reason for this?
I create the label in
- (void)viewDidLoad
{
myLabel = [[UILabel alloc]init];
[myLabel setText:@"Hi"];
[myLabel1 setText:@"Hello"];
[myLabel setFrame:CGRectMake(105, 130, 120, 30)];
[myLabel setBackgroundColor:[UIColor clearColor]];
[myLabel setTextColor:[UIColor whiteColor]];
[myLabel setTextAlignment:UITextAlignmentCenter];
[myLabel setAdjustsFontSizeToFitWidth:YES];
[self.view addSubview:myLabel];
[myLabel release];
}
In my first view controller
MySecondViewcontroller *showMyViewcontroller = [[ MySecondViewcontroller alloc]initWithNibName:@"MySecondViewcontroller" bundle:nil];;
showMyViewcontroller.myLabel = @"I cant set the text";
[self.navigationcontroller pushViewController: showMyViewcontroller animated:YES];
[showMyViewcontroller release];
What I am doing wrong here
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…