আমি আশা করি আপনি ইতিমধ্যে সমস্ত সমাধান পড়ে সমাধান পেয়েছেন। তবে আমি আমার সমাধানটি নীচে পেয়েছি। আমি আশা করছি যে আপনার ইতিমধ্যে একটি ঘর আছে UITextField। তাই প্রস্তুতি নেওয়ার জন্য কেবল পাঠ্য ক্ষেত্রের ট্যাগটিতে সারি সূচক রাখুন।
cell.textField.tag = IndexPath.row;
নীচের মতো বিশ্বব্যাপী সুযোগ সহ একটি activeTextFieldউদাহরণ তৈরি করুন UITextField:
@interface EditViewController (){
UITextField *activeTextField;
}
সুতরাং, এখন আপনি কেবল আমার কোডটি পেস্ট শেষে অনুলিপি করুন। এবং যোগ করতে ভুলবেন নাUITextFieldDelegate
#pragma mark - TextField Delegation
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
activeTextField = textField;
return YES;
}
- (void)textFieldDidEndEditing:(UITextField *)textField{
activeTextField = nil;
}
কীবোর্ড নিবন্ধন করুন notifications
#pragma mark - Keyboard Activity
- (void)registerForKeyboardNotifications
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasShown:)
name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillBeHidden:)
name:UIKeyboardWillHideNotification object:nil];
}
হ্যান্ডলগুলি কীবোর্ড Notifications:
UIKeyboardDidShowNotificationপাঠানো হলে কল করা হয়।
- (void)keyboardWasShown:(NSNotification*)aNotification
{
NSDictionary* info = [aNotification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, kbSize.height, 0.0);
[self.tableView setContentInset:contentInsets];
[self.tableView setScrollIndicatorInsets:contentInsets];
NSIndexPath *currentRowIndex = [NSIndexPath indexPathForRow:activeTextField.tag inSection:0];
[self.tableView scrollToRowAtIndexPath:currentRowIndex atScrollPosition:UITableViewScrollPositionTop animated:YES];
}
UIKeyboardWillHideNotificationপাঠানো হলে কল করা হয়
- (void)keyboardWillBeHidden:(NSNotification*)aNotification
{
UIEdgeInsets contentInsets = UIEdgeInsetsZero;
[self.tableView setContentInset:contentInsets];
[self.tableView setScrollIndicatorInsets:contentInsets];
}
এখন একটি জিনিস বাকি আছে, registerForKeyboardNotificationsপদ্ধতিতে পদ্ধতিতে নীচে কল করুন ViewDidLoad:
- (void)viewDidLoad {
[super viewDidLoad];
// Registering keyboard notification
[self registerForKeyboardNotifications];
// Your codes here...
}
আপনি হয়ে গেছেন, আশা করি আপনার textFieldsকীবোর্ডের সাহায্যে আর লুকানো থাকবে না।