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];
}
画像: