我已將3個uilabels添加到uitableview單元格中。我遇到的問題是當我滑動刪除時,單元格右側的UILabel不會移動,因此刪除按鈕和UILabel相互重疊。我已經發布了一些我的代碼如下。輸入編輯時在定製單元格上移動UILabel
我使用故事板開發了我的佈局,所以從我讀的內容來看,框架不會有幫助。
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *baseTableCellIdentifier = @"baseCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:baseTableCellIdentifier];
BaseInfo *infoAtIndex = [[[DataClass getInstance] allItems] objectAtIndex:[indexPath row]];
baseName = (UILabel *)[cell viewWithTag:1];
baseICAO = (UILabel *)[cell viewWithTag:2];
baseTime = (UILabel *)[cell viewWithTag:3];
[cell.contentView addSubview:baseName];
[cell.contentView addSubview:baseICAO];
[cell.contentView addSubview:baseTime];
[baseName setText:[infoAtIndex name]];
[baseICAO setText:[infoAtIndex icao]];
baseTimeZome = [NSTimeZone timeZoneWithName:[infoAtIndex timeZone]];
[baseDate setDateFormat:@"HH:mm"];
[baseDate setTimeZone:baseTimeZome];
NSString *baseTimeString = [baseDate stringFromDate:[NSDate date]];
[baseTime setFont:[UIFont boldSystemFontOfSize:20]];
[baseTime setText:baseTimeString] ;
return cell;
}
-(void)setEditing:(BOOL)editing animated:(BOOL)animated{
if (editing) {
//no idea what to put here
}else{
}
}
你有沒有試過設置你的'UILabel autoresizemask'?如果你沒有使用AutoLayout。 –