我已经用头撞墙了一个小时。这段代码创建的按钮应该会触发,但它们不会。
-(void)createToolbar {
[self.bar removeFromSuperview];
self.bar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, screenWidth, TOOLBAR_HEIGHT)];
[self.bar setTintColor:self.userInfo.screenColorTrans];
[self.bar setTranslucent:YES];
NSMutableArray *buttons = [[NSMutableArray alloc] init];
//It's the buttons send, trashButt, and editButt that appear and that change color when pressed (so I know they're registering user interaction) but that don't actually execute their methods.
UIBarButtonItem *send = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(share)];
[send setStyle : UIBarButtonItemStyleBordered];
UIBarButtonItem *flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:Nil];
if (self.ghhaiku.isUserHaiku) {
UIBarButtonItem *trashButt = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:self action:@selector(deleteHaiku)];
[trashButt setStyle : UIBarButtonItemStyleBordered];
UIBarButtonItem *editButt = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(editHaiku)];
[trashButt setTintColor : self.userInfo.screenColorTrans];
[editButt setTintColor : self.userInfo.screenColorTrans];
[buttons addObject:editButt];
[buttons addObject:trashButt];
}
//Add the buttons to the nav bar.
[buttons addObject:flex];
[buttons addObject:send];
self.bar.items=buttons;
[self.view addSubview:self.bar];
//Fade navigation bar: first delay, so that buttons are pressable, then fade.
double delayInSeconds = 3.5;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[UIView animateWithDuration:.5
animations:^{
self.bar.alpha = 0;
}];
});
}
这不是选择器方法中的错误——我知道这一点,因为如果我用唯一代码为“是”share
的方法替换,它仍然不会这样做。blahBlah
NSLog
关于我做错了什么的任何想法?