导航栏按钮没有显示在真实设备上

Yan*_*aim 2 iphone simulator navigationbar ios

我有一个导航栏,右侧有三个按钮(导航箭头+共享按钮).在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];
Run Code Online (Sandbox Code Playgroud)

Her*_*ker 5

我有类似的问题.

在我的例子中,.png文件已从项目和项目的工作目录中删除 - 出于某种原因.因此,它不再包含在Copy Bundle Resources中.

但奇怪的是,它显然还在模拟器上.就我而言,它甚至还在调试设备上.但是当构建一个用于临时分发的boulde时,它不在.因此,没有出现完整按钮(导航栏中的条形按钮项).用户无法调用与其关联的操作.

首先,我从模拟器中删除了应用程序.我尝试了两种方法,从模拟器的gui和文件系统/用户//库/应用程序支持/ iPhone模拟器/ 5.0 /应用程序/(应用程序ID)/ ...中删除它.在这两种情况下,在simulatore上运行应用程序重新安装了未使用的.png文件和许多其他有意从我的xcode项目中删除的文件.

但是,最终的解决方案是在xcode项目中再次包含png文件并将其分配给所有相关目标.在我的情况下,我还要改变图形,所以我包括新文件而不是旧文件.但我确信这个细节并不重要.

简短版本:1.如果您的png文件仍然是项目的一部分,则删除它.从项目文件夹中删除ist,只是为了保存.2.将png文件重新包含到项目中.3.创建您的构建并在空设备上尝试它.