Bar button not receiving touch

226 views Asked by At

I have 2 bar buttons on the tool bar , one is not working and the other is working. Some times when we touch the tip of the first bar button it will work, I think this has to be a problem with flexible space between them. I couldn't find any possible solution, any help will be appreciated! I'm pasting the code below

editbutton is the first button and mybutton is the second button

-(void) rightButtonToolbar:(UIBarButtonItem*)menuButton{

  UIToolbar* toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0,TOOLBAR_WIDTH ,44)];    

  NSMutableArray  *barButtons = [[NSMutableArray alloc]init];

  UIBarButtonItem *flexiSpace = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
   [barButtons addObject:flexiSpace];

if (showEditButton) 
{
    NSLog(@"showeditbutton");
   UIBarButtonItem *editButton = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(editOffer)];
[barButtons addObject:editButton];

    [editButton release];

}
UIBarButtonItem *myButton2 = [[UIBarButtonItem alloc] initWithTitle:@"Kopiren" style:UIBarButtonSystemItemAction target:self action:@selector(copyOffer)]; 
[barButtons addObject:myButton2];  
if (menuButton != nil) {
    menuButtonShown=YES;
    [barButtons addObject:menuButton];  
}
else {
    menuButtonShown=NO;
}
[toolbar setItems:barButtons animated:YES];
UIBarButtonItem *rightBarButton = [[UIBarButtonItem alloc]initWithCustomView:toolbar];
[self.navigationItem setRightBarButtonItem:rightBarButton animated:YES];
[barButtons release];
    [flexiSpace release];
[rightBarButton release];
[toolbar release];
    [myButton2 release];
}
0

There are 0 answers