我有以下代码:将按钮添加到工具栏底部
self.shareButton=[[UIButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 35, 35)];
[shareButton setBackgroundColor:[UIColor blueColor]];
[shareButton setBackgroundImage:[UIImage imageNamed:@"share_button"] forState:UIControlStateNormal];
[shareButton setBackgroundImage:[UIImage imageNamed:@"share_button_pressed"] forState:UIControlStateHighlighted];
[shareButton addTarget:self action:@selector(shareButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
[self.navigationController setToolbarItems:[NSArray arrayWithObject:shareButton] animated:YES];
为什么我不能看到工具栏按钮?有什么问题?
尝试使用UIBarButtonItem而不是UIButton? – meggar 2012-01-13 16:37:50
新增了'UIBarButtonItem * shareBarButton = [[UIBarButtonItem alloc] initWithCustomView:shareButton];'并更改了'[self.navigationController setToolbarItems:[NSArray arrayWithObject:shareBarButton] animated:YES];'问题依然存在 – Oleg 2012-01-13 16:42:45