我有一个导航栏,右侧有三个按钮(导航箭头+共享按钮)。在Iphone模拟器上,我可以很好地看到它们,并且它们工作得很完美。当我在真正的Iphone 4设备上安装应用程序时,按钮不会显示! (我的模拟器是iPhone 3,如果它metter)。 我的代码是:没有在真实设备上显示的导航栏按钮
UIToolbar *tools = [[UIToolbar alloc]
initWithFrame:CGRectMake(0, 0, 70.0f, 44.01f)]; // 44.01 shifts it up 1px for some reason
tools.clearsContextBeforeDrawing = NO;
tools.clipsToBounds = NO;
tools.tintColor = [UIColor colorWithWhite:0.305f alpha:0.0f]; // closest I could get by eye to black, translucent style.
// anyone know how to get it perfect?
tools.barStyle = -1; // clear background
NSMutableArray *buttons = [[NSMutableArray alloc] initWithCapacity:3];
// Create a standard refresh button.
UIBarButtonItem *bi = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"share.png"] style:UIBarButtonItemStylePlain target:self action:@selector(shareClicked)];
//initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refresh:)];
[buttons addObject:bi];
[bi release];
// Create a spacer.
bi = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"scroll left.png"] style:UIBarButtonItemStylePlain target:self action:@selector(upClicked)];
//bi.width = 12.0f;
[buttons addObject:bi];
[bi release];
// Add profile button.
bi = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"scroll right.png"] style:UIBarButtonItemStylePlain target:self action:@selector(downClicked)];
//bi.style = UIBarButtonItemStyleBordered;
[buttons addObject:bi];
[bi release];
// Add buttons to toolbar and toolbar to nav bar.
[tools setItems:buttons animated:NO];
[buttons release];
UIBarButtonItem *twoButtons = [[UIBarButtonItem alloc] initWithCustomView:tools];
[tools release];
self.navigationItem.rightBarButtonItem = twoButtons;
[twoButtons release];
你有没有这样的运气? – stan229
是的,打开图像,然后保存它(“另存为”)解决了我的问题 –