Unresponsive UIToolbar – Subview of a UIWebView

Discussion in 'iOS Programming' started by eli8527, May 8, 2010.

  1. eli8527 macrumors newbie

    eli8527

    Joined:
    Jul 18, 2008
    #1
    Hi Everyone, I'm encountering a problem in my iPhone/iPad Application in which I have a UIToolbar as a subview of a UIWebView. However, when I add buttons to the toolbar, these buttons are not responsive... Any help would be much appreciated!

    Here is my code:
    Code:
    - (void)viewDidLoad {
        [super viewDidLoad];
    	
    	resourcesViewController.scalesPageToFit = YES;
    	
    	[resourcesViewController loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"google.com"]]];
    	
    	//ToolBar Code
    	toolbar = [[UIToolbar alloc] init];
    	[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    	[toolbar sizeToFit];
    	
    	//Button Code
    	studentDirectory = [[UIBarButtonItem alloc] initWithTitle:@"Student Directory" style:UIBarButtonItemStyleBordered target:self action:@selector(stuDir:)];
    	passwordReset = [[UIBarButtonItem alloc] initWithTitle:@"Password Reset" style:UIBarButtonItemStyleBordered target:self action:@selector(resetPass:)];
    	[toolbar setItems:[NSArray arrayWithObjects:studentDirectory,passwordReset,nil]];
    	
    	if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    	{
    		// The device is an iPad running iPhone 3.2 or later.
    	
           //Toolbar
    		if ([[UIDevice currentDevice] orientation]	== UIDeviceOrientationPortrait || [[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown) {
    			[toolbar setFrame:CGRectMake( 0, -31, 768, 31)];
    			[resourcesViewController addSubview:toolbar];
    		}
    		else {
    		[toolbar setFrame:CGRectMake( 0, -31, 1024, 31)];
    			[resourcesViewController addSubview:toolbar];
    		}
    			
    	}
    	else
    	{
    		// The device is an iPhone or iPod touch.
    		[toolbar setFrame:CGRectMake( 0, -32, 320, 32)];
    		[resourcesViewController addSubview:toolbar];
    	}
    	
    
    	
    	
    
    }
    
    -(void)resetPass:(id)sender {
    	NSLog(@"I WAS PRESSED :D");
    	[resourcesViewController loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"google.com"]]];
    
    }
    	
    -(void)stuDir:(id)sender {
    	NSLog(@"I WAS PRESSED :D");
    	[resourcesViewController loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"google.com"]]];
    }
    
    
     
  2. mathcolo macrumors 6502a

    Joined:
    Sep 14, 2008
    Location:
    Massachusetts
    #2
    I've actually been wondering the same thing! I'd like to create a bookmarks-toolbar sort of thing as a subview of a UIWebView (like Mobile Safari), but I've not been able to figure out how. Any thoughts on this would be appreciated.... thanks!
     

Share This Page