0

为什么不改变uilabel?

我创建了一些类,但无法覆盖设置器

.h 文件的代码

@interface ViewController : UIViewController
{
    UILabel * _lblName;
}
@property (retain, nonatomic) IBOutlet UILabel * lblName;

@end

.m 文件的代码

@synthesize lblName = _lblName;

 

- (void)setLblName:(UILabel *)lblName{
if(![_lblName isEqual:lblName]){
[_lblName release];
_lblName = [lblName retain];}}

 

- (IBAction)didCustomBtnClick:(id)sender {
UILabel* lbl = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 30.0)];
lbl.text = @"Duck";
self.lblName = lbl;
[lbl release];}
4

0 回答 0