【发布时间】:2012-10-18 15:07:01
【问题描述】:
我在viewDidLoad 中有以下代码(用于在导航栏中设置标题),该代码因“发送到已释放实例的消息”错误而崩溃:
UILabel * label = [[[UILabel alloc] initWithFrame:CGRectMake(0,0,45,45)] autorelease];
label.textColor = [UIColor whiteColor];
label.backgroundColor=[UIColor clearColor];
label.font = [UIFont boldSystemFontOfSize:20];
label.font = [UIFont fontWithName:@"Mayfield Regular" size:15];
self.navigationItem.titleView = label;
label.text=@"SEARCH"; //CUSTOM TITLE
[label sizeToFit];
[label release];
我该如何解决这个问题?
感谢您的帮助
【问题讨论】:
-
删除
autorelease或[label release]
标签: objective-c ios memory-management