[cpp]
- (id)init
{
self = [super init];
if (self) {
self.wantsFullScreenLayout = YES;
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackTranslucent;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillHideNotification object:nil];
}
return self;
}
[cpp]
-(void)loadview
{
titlefield.delegate = self;
}
[cpp]
#pragma mark -
#pragma mark - textfield delete
-(void)textFieldDidBeginEditing:(UITextField *)textField
{
}
-(void)textFieldDidEndEditing:(UITextField *)textField
{
[self adjustPanelsWithKeybordHeight:0];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
NSLog(@"should return");
[self.sendpanel.titlefield resignFirstResponder];
return YES;
}
- (void)keyboardWillChangeFrame:(NSNotification *)notification
{
NSLog(@"keyboardWillChangeFrame");
NSValue *keyboardBoundsValue = [[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey];
CGRect keyboardBounds;
[keyboardBoundsValue getValue:&keyboardBounds];
NSLog(@"height = %f",keyboardBounds.size.height);
[self adjustPanelsWithKeybordHeight:keyboardBounds.size.height];
}
-(void)adjustPanelsWithKeybordHeight:(float)height
{
sendpanel.frame = CGRectMake(0, 435-height, sendpanel.frame.size.width, sendpanel.frame.size.height);
progresspanel.frame = CGRectMake(0, 400-height, progresspanel.frame.size.width, progresspanel.frame.size.height);
}
[html]
-(void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
}