
I have a navigation bar with a custom view as an element of the right button. User view has two buttons. But when I touch the area below the navigation bar on the right side, it triggers a button click event. I checked the button frames and view, changing the background color, they are all set perfectly. I checked the default iOS apps like clock, calendar, settings, notes, etc., They all have the same behavior. Touching the red rectangle in the screenshots (the default iOS calendar application) triggers a button touch event, it also happens with my application.
Here is the code ..
UIView* navigationButtonsView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 100.0f, 44.0f)]; UIButton *p = [UIButton buttonWithType:UIButtonTypeCustom]; [p setImage:[UIImage imageNamed:@"PBtn.png"] forState:UIControlStateNormal]; [p addTarget:self action:@selector(PButtonPushed:) forControlEvents:UIControlEventTouchUpInside]; [p setFrame:CGRectMake(43, 0, 57, 44)]; [navigationButtonsView addSubview:p]; UIButton *o = [UIButton buttonWithType:UIButtonTypeCustom]; [o addTarget:self action:@selector(oButtonPushed:) forControlEvents:UIControlEventTouchUpInside]; [o setFrame:CGRectMake(0, 0, 38, 44)]; [o setImage:[UIImage imageNamed:@"O.png"] forState:UIControlStateNormal]; [navigationButtonsView addSubview:o]; UIBarButtonItem *barItem = [[UIBarButtonItem alloc] initWithCustomView:navigationButtonsView]; [musicVC.navigationItem setRightBarButtonItem: barItem animated:NO];
How to change this default iOS behavior for navigation bar buttons? Because m has some user interface right below these buttons, and its upper area is not responding because of this. Thanks in advance.
source share