1
我想知道是什麼使一個的UITextField適合一個UITableView細胞的最佳途徑。最佳路線,以適應的UITextField到的UITableView細胞
我已經使用這個方法之前:
@implementation UITextField (custom)
- (CGRect)textRectForBounds:(CGRect)bounds {
return CGRectMake(bounds.origin.x + 0, bounds.origin.y + 10,
bounds.size.width - 30, bounds.size.height - 16);
}
- (CGRect)editingRectForBounds:(CGRect)bounds {
return [self textRectForBounds:bounds];
}
@end
但是這會導致一個問題:
Category is implementing a method which will also be implemented by its primary class
雖然我見過的方式來隱藏這些警告,感覺這更是一個黑客攻擊比正確的方法。
什麼是適合的UITextField到細胞的最佳途徑。這是我的領域:
// Username field
usernameField = [[UITextField alloc] initWithFrame:(CGRectMake(10, 0, 300, 43))];
usernameField.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
它輸入到這樣的小區:
if (indexPath.row == 0) {
[cell.contentView addSubview:usernameField];
}
圖片:
你能解釋一下如何,請? – StuartM 2013-02-25 22:42:59
剛剛添加了有關layoutSubviews方法的詳細信息。我假設你已經有一個自定義的UITableViewCell? – 2013-02-25 22:45:35
這會影響所有子視圖嗎?我編程設置我所有的子視圖,這會影響你明確設置的UITableViewCell所有的人或僅文本字段 – StuartM 2013-02-25 22:48:14