我在工具栏上有 2 个栏按钮,一个不工作,另一个工作。有时当我们触摸第一个栏按钮的尖端时它会起作用,我认为这必须是它们之间的灵活空间的问题。我找不到任何可能的解决方案,任何帮助将不胜感激!我正在粘贴下面的代码
editbutton 是第一个按钮,mybutton 是第二个按钮
-(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];
}