20th Tue
iOS キーボードに表示に連動した UI の移動。
ruby>>
- (void)
viewWillAppear:(BOOL)p
{ [ NSNotificationCenter.defaultCenter
addObserverForName:UIKeyboardWillShowNotification
object:self.view.window
queue:nil
usingBlock:^( NSNotification* p )
{ [ UIView
animateWithDuration:[ [ p.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey ] doubleValue ]
animations:
^{ self.view.frame = CGRectMake
( self.view.frame.origin.x
, self.view.frame.origin.y
, self.view.frame.size.width
, self.view.frame.size.height - [ [ p.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey ] CGRectValue ].size.height
);
}
];
}
];
[ NSNotificationCenter.defaultCenter
addObserverForName:UIKeyboardWillHideNotification
object:self.view.window
queue:nil
usingBlock:^( NSNotification* p )
{ [ UIView
animateWithDuration:[ [ p.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey ] doubleValue ]
animations:
^{ self.view.frame = CGRectMake
( self.view.frame.origin.x
, self.view.frame.origin.y
, self.view.frame.size.width
, self.view.frame.size.height + [ [ p.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey ] CGRectValue ].size.height
);
}
];
}
];
}
- (void)
viewDidDisappear:(BOOL)p
{ [ NSNotificationCenter.defaultCenter removeObserver:self ];
}
<<--
posted by
Saturn on Tue 20 Aug 2013 at 13:58 with 0 comments