Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 04-20-2009, 11:08 AM   #12 (permalink)
jtmille3
New Member
 
Join Date: Jan 2009
Posts: 2
Default My Solution

This thread got me started, so here's my solution. As with the intial approach on this thread I retrieve the keyboard from the notification. I then take it one step further. After adding my UIToolbar to the keyboard I rebound the keyboard view. So the toolbar and they keyboard will both collect touch events within the Keyboard class frame. Handles rotation as well.

Code:
- (void)keyboardWillShow:(NSNotification *)notification 
{	
    for (UIWindow *keyboardWindow in [[UIApplication sharedApplication] windows]) {
		
        // Now iterating over each subview of the available windows
        for (UIView *keyboard in [keyboardWindow subviews]) {
			
            // Check to see if the description of the view we have referenced is UIKeyboard.
            // If so then we found the keyboard view that we were looking for.
            if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES) {
				NSValue *v = [[notification userInfo] valueForKey:UIKeyboardBoundsUserInfoKey];
				CGRect kbBounds = [v CGRectValue];
				
				if(keyboardToolbar == nil) {
					keyboardToolbar = [[UIToolbar alloc] initWithFrame:CGRectZero];
					keyboardToolbar.barStyle = UIBarStyleBlackTranslucent;
					
					UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Dismiss" style:UIBarButtonItemStyleBordered target:self action:@selector(dismissKeyboard:)];
					NSArray *items = [[NSArray alloc] initWithObjects:barButtonItem, nil];
					[keyboardToolbar setItems:items];	
					[items release];	
				}				
				
				[keyboardToolbar removeFromSuperview];
				keyboardToolbar.frame = CGRectMake(0, 0, kbBounds.size.width, 30);
				[keyboard addSubview:keyboardToolbar];
				keyboard.bounds = CGRectMake(kbBounds.origin.x, kbBounds.origin.y, kbBounds.size.width, kbBounds.size.height + 60);
				
				for(UIView* subKeyboard in [keyboard subviews]) {
					if([[subKeyboard description] hasPrefix:@"<UIKeyboardImpl"] == YES) {
						subKeyboard.bounds = CGRectMake(kbBounds.origin.x, kbBounds.origin.y - 30, kbBounds.size.width, kbBounds.size.height);	
					}						
				}
            }
        }
    }
}
jtmille3 is offline   Reply With Quote
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 24,327
Threads: 39,123
Posts: 171,541
Top Poster: smasher (2,577)
Welcome to our newest member, tpearce
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:18 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.