1
-(void)keyboardWillShow : (NSNotification *)sender {
    @try  {
//      NSLog(@"notification in first view");
        for (UIWindow *keyboardWindow in [[UIApplication sharedApplication] windows]) { 
            for (UIView *keyboard in [keyboardWindow subviews]) {
                if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES) {
                    NSValue *v = [[sender userInfo] valueForKey:UIKeyboardBoundsUserInfoKey];
                    CGRect kbBounds = [v CGRectValue];
                    if(keyboardToolbar == nil) {
                        keyboardToolbar = [[UIToolbar alloc] initWithFrame:CGRectZero];
                        keyboardToolbar.barStyle=UIBarStyleBlackOpaque;
                        keyboardToolbar.tintColor = [UIColor colorWithRed:0.6 green:0.2 blue:0.6039 alpha:1];
                        UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleBordered target:self action:@selector(dismissKeyboard)];
                        UIBarButtonItem *flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
                        NSArray *items = [[NSArray alloc] initWithObjects:flex, barButtonItem, nil];
                        [keyboardToolbar setItems:items];
                        [items release];
                    }               
                    [keyboardToolbar removeFromSuperview];
                    keyboardToolbar.frame = CGRectMake(0, 0, kbBounds.size.width, 45);
                    [keyboard addSubview:keyboardToolbar];
                    keyboard.bounds = CGRectMake(kbBounds.origin.x, kbBounds.origin.y, kbBounds.size.width, kbBounds.size.height + 87);

                    for(UIView* subKeyboard in [keyboard subviews]) {
                        if([[subKeyboard description] hasPrefix:@"<UIKeyboardImpl"] == YES) {
                            subKeyboard.bounds = CGRectMake(kbBounds.origin.x, kbBounds.origin.y - 45, kbBounds.size.width, kbBounds.size.height);  
                        }                       
                    }
                }
            }
        }
    } @catch (NSException * e) {
//      NSLog(@"Problem in keyboardWillShow:%@",e);
    }

}

but this code works in iphone sdk 3.0 but this code does not work in iphone SDK 4.0 it says that uikeyboard bounce user info key deprecated in iphone 4.0 OS it does not create toolbar with done button please guide me how could i do that

BenMorel
  • 34,448
  • 50
  • 182
  • 322
hardik
  • 254
  • 4
  • 15

1 Answers1

1

You can try with

if ([[currentWindow description] hasPrefix:@"<UITextEffectsWindow"])
        {
            NSLog(@"Key board found");
}

But you cannot hide I think. You can put your custom view on it but hide the UIKeyboard I don't think it will work for iOS 4.

Taryn
  • 242,637
  • 56
  • 362
  • 405
iphonejpg
  • 11
  • 1