20th
Tue
iOS キーボードに表示に連動した UI の移動。
1 - (void) 2 viewWillAppear:(BOOL)p 3 { [ NSNotifica tionCenter .defaultCen ter 4 addObserve rForName:UIKeyboard WillShowNo tification 5 object:self.view.window 6 queue:nil 7 usingBlock :^( NSNotifica tion* p ) 8 { [ UIView 9 animateWit hDuration: [ [ p.userInfo objectForK ey:UIKeyboard AnimationD urationUse rInfoKey ] doubleValu e ] 10 animations : 11 ^{ self.view.frame = CGRectMake 12 ( self.view.frame.origin.x 13 , self.view.frame.origin.y 14 , self.view.frame.size.width 15 , self.view.frame.size.height - [ [ p.userInfo objectForK ey:UIKeyboard FrameEndUs erInfoKey ] CGRectValu e ].size.height 16 ); 17 18 } 19 ]; 20 } 21 ]; 22 [ NSNotifica tionCenter .defaultCen ter 23 addObserve rForName:UIKeyboard WillHideNo tification 24 object:self.view.window 25 queue:nil 26 usingBlock :^( NSNotifica tion* p ) 27 { [ UIView 28 animateWit hDuration: [ [ p.userInfo objectForK ey:UIKeyboard AnimationD urationUse rInfoKey ] doubleValu e ] 29 animations : 30 ^{ self.view.frame = CGRectMake 31 ( self.view.frame.origin.x 32 , self.view.frame.origin.y 33 , self.view.frame.size.width 34 , self.view.frame.size.height + [ [ p.userInfo objectForK ey:UIKeyboard FrameEndUs erInfoKey ] CGRectValu e ].size.height 35 ); 36 37 } 38 ]; 39 } 40 ]; 41 } 42 43 - (void) 44 viewDidDis appear:(BOOL)p 45 { [ NSNotifica tionCenter .defaultCen ter removeObse rver:self ]; 46 } 47 48
posted by
Saturn
on Tue 20 Aug 2013
at 13:58