I'm displaying a datepicker with a toolbar and one button (close button) above a webview in my app. This is the code:
// create picker view
UIView* container= [[UIView alloc] initWithFrame:CGRectMake([x doubleValue], [y doubleValue], 320.0, 216.0 + 44.0)];
UIToolbar* toolbar= [[UIToolbar alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 44.0)];
UIDatePicker* picker= [[UIDatePicker alloc] initWithFrame:CGRectMake(0.0, 0.0 + 44.0, 320.0, 216.0)];
[container addSubview:toolbar];
[container addSubview:picker];
[toolbar release];
[picker release];
UIBarButtonItem* item= [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissPicker:)];
NSArray* buttons = [NSArray arrayWithObjects: item,nil];
[toolbar setItems: buttons animated:NO];
[item release];
[self.webView addSubview:container];
Works, except for the fact that the button is triggered (pressed-down) when i click like 20 points to the right of the button, and it even fires the action when i click about 5-10 points to the right of the button. (http://i42.tinypic.com/2nssv0m.jpg)
Does anybody know why this happens?
To me, this is a known issue. You can even see this working with iPhone native applications such as "Mail" and with others as well.