Al seçili UİTextField gidin ve Klavye ile Gizli Önlemek için UİTableView
UIViewController
(UITableViewController
) UITextField
tablodaki bir görünümü var.
Eğer tablo, görünüm, *8,* Bir tablo otomatik olarak textField
klavye ile gizli engellemek için düzenlenen ilerleyin. Ama UIViewController
üzerinde değildir.
Bunu gerçekleştirmek için denemek için birden fazla yol üzerinden okuma günleri birkaç denedim ve işe alamıyorum. Aslında bu verilirse en yakın şey
-(void) textFieldDidBeginEditing:(UITextField *)textField {
// SUPPOSEDLY Scroll to the current text field
CGRect textFieldRect = [textField frame];
[self.wordsTableView scrollRectToVisible:textFieldRect animated:YES];
}
Ancak bu sadece en üst satır için tablo kayar. Kolay bir görev gibi görünüyor ne hayal kırıklığı bir kaç gün oldu.
Aşağıdaki tableView hücreleri oluşturmak için kullanıyorum:
- (UITableViewCell *)tableView:(UITableView *)aTableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *identifier = [NSString stringWithFormat: @"%d:%d", [indexPath indexAtPosition: 0], [indexPath indexAtPosition:1]];
UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:identifier] autorelease];
cell.accessoryType = UITableViewCellAccessoryNone;
UITextField *theTextField = [[UITextField alloc] initWithFrame:CGRectMake(180, 10, 130, 25)];
theTextField.adjustsFontSizeToFitWidth = YES;
theTextField.textColor = [UIColor redColor];
theTextField.text = [textFieldArray objectAtIndex:indexPath.row];
theTextField.keyboardType = UIKeyboardTypeDefault;
theTextField.returnKeyType = UIReturnKeyDone;
theTextField.font = [UIFont boldSystemFontOfSize:14];
theTextField.backgroundColor = [UIColor whiteColor];
theTextField.autocorrectionType = UITextAutocorrectionTypeNo;
theTextField.autocapitalizationType = UITextAutocapitalizationTypeNone;
theTextField.clearsOnBeginEditing = NO;
theTextField.textAlignment = UITextAlignmentLeft;
//theTextField.tag = 0;
theTextField.tag=indexPath.row;
theTextField.delegate = self;
theTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
[theTextField setEnabled: YES];
[cell addSubview:theTextField];
[theTextField release];
}
return cell;
}
Eğer bir şekilde textFieldDidBeginEditing
yöntemi indexPath.row
verebileceksem, tableView doğru ilerleyin alabilirim sanıyorum?
Herhangi bir yardım için teşekkür ederiz.
CEVAP
- (void)keyboardWillShow:(NSNotification *)sender
{
CGSize kbSize = [[[sender userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
NSTimeInterval duration = [[[sender userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
[UIView animateWithDuration:duration animations:^{
UIEdgeInsets edgeInsets = UIEdgeInsetsMake(0, 0, kbSize.height, 0);
[aTableView setContentInset:edgeInsets];
[aTableView setScrollIndicatorInsets:edgeInsets];
}];
}
- (void)keyboardWillHide:(NSNotification *)sender
{
NSTimeInterval duration = [[[sender userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
[UIView animateWithDuration:duration animations:^{
UIEdgeInsets edgeInsets = UIEdgeInsetsZero;
[aTableView setContentInset:edgeInsets];
[aTableView setScrollIndicatorInsets:edgeInsets];
}];
}
Ve - (void)viewDidLoad
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
Sonra
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
Ne kadar klavye varsa bir UİTextField ...
Nasıl OS için gizli olmaktan kaydırma ...
Nasıl seçili UİTableView bir hücre seç...
Nasıl bir anahtar UİTextField dönüş ba...
Nasıl JSP dosyaları Java kod önlemek i...