我在动态细胞高度方面存在一些问题。你可以在屏幕上看到它。以红色突出显示的问题我在IOS 7上没有这个问题。
UPD。
heightForRowAtIndexPath方法如下所示:
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath: (NSIndexPath *) indexPath {
Contact* contact = [contacts objectAtIndex: indexPath.row];
CGFloat height = 170.0f;
if (contact.name ==nil) {
height -=25.0f;
}
if (contact.phone ==nil) {
height -=25.0f;
}
if (contact.email==nil) {
height -=25.0f;
}
if (contact.address==nil) {
height -=40.0f;
}
return height;
}
但是我不知道为什么它在ios7上正确使用iphone 5而不能在带有ios6.1的iphone 4上工作。
UPD2
layoutSubviews方法:
-(void)layoutSubviews {
CGFloat phoneY = 65.0f;
CGFloat emailY = 90.0f;
CGFloat addressY = 115.0f;
CGRect contactNameLabelFrame = contactNameLabel.frame;
CGRect nameLabelFrame = nameLabel.frame;
CGRect phoneLabelFrame = contactPhoneLabel.frame;
CGRect phoneButtonFrame = phoneButton.frame;
CGRect emailButtonFrame = emailButton.frame;
CGRect emailLabelFrame = contactEmailLabel.frame;
CGRect addressLabelFrame = contactAddressLabel.frame;
CGRect addressButtonFrame = addressButton.frame;
if (contact.name == nil) {
contactNameLabelFrame.size.width = 0.0f;
nameLabelFrame.size.width = 0.0f;
phoneY -=25.0f;
emailY -= 25.0f;
addressY -= 25.0f;
} else {
contactNameLabelFrame.size.width = 60.0f;
nameLabelFrame.size.width = 212.0f;
}
if (contact.phone == nil) {
phoneLabelFrame.size.width = 0.0f;
phoneButtonFrame.size.width = 0.0f;
emailY -= 25.0f;
addressY -= 25.0f;
} else {
phoneLabelFrame.size.width = 60.0f;
phoneLabelFrame.origin.y = phoneY;
phoneButtonFrame.size.width = 212.0f;
phoneButtonFrame.origin.y = phoneY - 4;
}
if (contact.email == nil) {
emailLabelFrame.size.width = 0.0f;
emailButtonFrame.size.width = 0.0f;
addressY -= 25.0f;
} else {
emailLabelFrame.origin.y = emailY;
emailLabelFrame.size.width = 60.0f;
emailButtonFrame.origin.y = emailY - 4;
emailButtonFrame.size.width = 212.0f;
}
if (contact.address == nil) {
addressLabelFrame.size.width = 0.0f;
addressButtonFrame.size.width = 0.0f;
} else {
addressLabelFrame.origin.y = addressY;
addressLabelFrame.size.width = 60.0f;
addressButtonFrame.origin.y = addressY + 2;
addressButtonFrame.size.width = 212.0f;
}
[contactNameLabel setFrame:contactNameLabelFrame];
[nameLabel setFrame:nameLabelFrame];
[contactPhoneLabel setFrame:phoneLabelFrame];
[phoneButton setFrame:phoneButtonFrame];
[contactEmailLabel setFrame:emailLabelFrame];
[emailButton setFrame:emailButtonFrame];
[contactAddressLabel setFrame:addressLabelFrame];
[addressButton setFrame:addressButtonFrame];
}
UPD3
谢谢大家。我找到了问题的根源。我添加到layoutSubviews方法[super layoutSubviews];