//由此可知,一開始new的cell因為不知道你的tableView的frame,所以會先給定一個default值!你要自行去修改。
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
NSLog(@"%@ cellForRowAtIndexPath cell.frame.size.width 1 =%f", [self class], cell.frame.size.width);
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
NSLog(@"%@ cellForRowAtIndexPath cell.frame.size.width 2 =%f", [self class], cell.frame.size.width);
[cell setFrame:CGRectMake(0.f, 0.f, tableView.frame.size.width, tableView.frame.size.height)];
}
NSLog(@"%@ cellForRowAtIndexPath cell.frame.size.width 3 =%f", [self class], cell.frame.size.width);
這很重要! 謝謝!
回覆刪除