iphone label初始化碰到的问题
1,在viewDidLoad时,初始化label,代码如下:
UILabel *labelcopy = [[UILabel alloc] initWithFrame:CGRectZero];
labelcopy.textColor = [UIColor redColor];
labelcopy.text = @"123455";
labelcopy.frame = CGRectMake(0,0, 100, 100);
label = labelcopy;
[self.view addSubview:label];
[labelcopy release];
以上代码运行正常。
但是用以下代码就不能显示
UILabel *labelcopy = [[UILabel alloc] initWithFrame:CGRectZero];
labelcopy.textColor = [UIColor redColor];
labelcopy.text = @"123455";
labelcopy.frame = CGRectMake(0,0, 100, 100);
label = labelcopy;
[labelcopy release];
[self.view addSubview:label];
这是label就不能正常显示了。太神奇了,求解答。