今天中午做页面的时候遇到个恶心的问题,该操作本来是为了避免该控件重复创建的,俗称懒加载。但是在实际运行中会在
UITableView* cityTable = [[UITableView alloc] init];
和
[self addSubview:cityTable];
之间一直重复循环,最终报死。不明所以。
- (UITableView*)cityTable
{
if (!_cityTable) {
UITableView* cityTable = [[UITableView alloc] init];
cityTable.frame = CGRectMake(0, 0, ScreenWidth / 3, 200);
cityTable.delegate = self;
cityTable.dataSource = self;
cityTable.backgroundColor = UIColorFromRGB(0xf2f2f2);
cityTable.separatorStyle = UITableViewCellSeparatorStyleNone;
[self addSubview:cityTable];
_cityTable = cityTable;
}
return _cityTable;
}
网友评论