連絡先アプリケーションの追加/編集ビューで、フィールドの「Return」キーを押すと、各UITextFieldを順番に表示します。これらのフィールドはUITableViewCell内にあるようです。これを行うには良い方法は何ですか?UITableViewCell内のUITextField間の移動
テーブル内にない一連のUITextFieldがある場合は、 [self.view viewWithTag:tag]
を呼び出して、ビューのリストとそれらを循環させるための使用方法を取得できます。しかし、テーブル内では、私は1つのビューを取得し、私はこれを変換する方法がわからない。
-(BOOL)textFieldShouldReturn:(UITextField *)textField {
// Find the next entry field
for (UIView *view in [self entryFields]) {
if (view.tag == (textField.tag + 1)) {
[view becomeFirstResponder];
break;
}
}
return NO;
}
/*
Returns an array of all data entry fields in the view.
Fields are ordered by tag, and only fields with tag > 0 are included.
Returned fields are guaranteed to be a subclass of UIResponder.
From: http://iphoneincubator.com/blog/tag/uitextfield
*/
- (NSArray *)entryFields {
if (!entryFields) {
self.entryFields = [[NSMutableArray alloc] init];
NSInteger tag = 1;
UIView *aView;
while (aView = [self.view viewWithTag:tag]) {
if (aView && [[aView class] isSubclassOfClass:[UIResponder class]]) {
[entryFields addObject:aView];
}
tag++;
}
}
return entryFields;
}