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:
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"]]];
}