вот мой код:UIKeyboardWillShowNotification и слайдов, когда клавиатура отображается
-(void)setViewMovedUp:(BOOL)movedUp
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.2]; // if you want to slide up the view
[UIView setAnimationBeginsFromCurrentState:YES];
CGRect rect = scroll.frame;
if (movedUp)
{
rect.size.height += kOFFSET_FOR_KEYBOARD;
rect.origin.y -= kOFFSET_FOR_KEYBOARD;
}
else
{
rect.size.height -= kOFFSET_FOR_KEYBOARD;
rect.origin.y += kOFFSET_FOR_KEYBOARD;
}
scroll.frame = rect;
[UIView commitAnimations];
}
- (void)keyboardWillHide:(NSNotification *)notif {
[self setViewMovedUp:NO];
}
- (void)keyboardWillShow:(NSNotification *)notif{
[self setViewMovedUp:YES];
}
- (void)viewWillAppear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification object:self.view.window];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification object:self.view.window];
}
- (void)viewWillDisappear:(BOOL)animated
{
// unregister for keyboard notifications while not visible.
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
}
Проблема заключается в том, как я могу это spezify работать только на TextView3, не TextView2 или TextView1. BackGround - это то, что TextView1 и TextView2 не нужны, потому что есть поверх моего представления. Только TextView3 является TextView, который не читается, потому что клавиатура накладывается, и представление должно быть исправлено, чтобы читать то, что я пишу.
Можете ли вы дать мне код для этого, пожалуйста? Im на начальном уровне в Objective C – Kovu
Проверьте мое редактирование plz. –