Monday 15 September 2014

objective c - iOS virtual keyboard size without notification center -


I need to scroll my scrollview, when the text file is tapped, which is to press the virtual keyboard. I [self.scrollView setContentOffset: animated scrollPoint: Yes]; I call . To get the viewing area of ​​the screen, I need to explicitly have KB size.

I'm familiar with

  NSDictionary * info = [notification userInfo]; CGSize kbSize = [self.view Convert: [info [UIKeyboardFrameBeginUserInfoKey] CGRectValue] View: Zero]. Shape;   

However, this does not work for me, because when the user is potentially dragging on a half-hidden textfield, I do not get keyboard notifications.

So I call the method in textFieldDidBeginEditing: , which will be sent to the message before the keyboard, and so I do not know the KB size on the first tape.

So the question is: Is it possible to get KB size without applying the same notification? Not programmatic, hardcoding

You're doing it wrong.

You also listen to the keyboard show / hide notifications and then need to adjust your screen.

Here is a specimen skeleton code:

  - (zero) seeWeapper: (BOOL) animated [[Super ViewWhipper: Animated]; NSNotificationCenter * nc = [NSNotificationCenter defaultCenter]; [Nc addObserver: Self Selector: @Selector (Keyboard ChangeStatus :) Name: UIKeyboardWillShowNotification Object: Zero]; [Nc addObserver: Self Selector: @Selector (Keyboard ChangeStatus :) Name: UIKeyboardWillHideNotification Object: Zero]; } - (void) from Drishyviseshrup: (BOOL) animated ([Super Drishyvhiakar: animated]; NSNotificationCenter * nc = [NSNotificationCenter defaultCenter]; [NC Htayenobsrhwar: own name: UIKeyboardWillShowNotification object: nil]; [NC Htayenobsrhwar: own name : UIKeyboardWillHideNotification object: nil];} get #pragma mark - keyboard size - (minus) keyboard change Status: (NSNotification *) to receive notification {// size! Siajiaraf Kiboarderekt [[[Information User Ifo] Objec T Foreki: Uaikeboardfremaendusrinfokey] joins: And to amp; Keyboard; Kiboardhait = display Kiboarderait. // text, move your view at the top. [Self-step sequence: Notification Kiboardhait: Kiboardhait];} # Prgma see Mark Moving - (zero lead) Jaaawu: (Ansantifikeshn *) notification keyboard height: (Int) height {[Uaiviuvi Shuruanumtiya: zero manual placenta]; [UIView Setanime Nkrn period: 0.3]; [UIView Setanimeshnbginfrnttantःtet: YES]; Sijiarsiti Rikt = self.view.frame; if ([[notification name, Avl: UIKeyboardWillHideNotification]) come back to {// normalcy. Rect.origin.y = 0; HasScrolledToTop = YES; } Else {// 1. Continue opening scene next to the text field that keyboard (you come up with the need to adjust the price here), rect.origin.y = -height; } Self.view.frame = rect; [UIView commitAnimations]; }    

No comments:

Post a Comment