2013-04-26 66 views
0

我試圖製作一個音頻播放器,並在底部有一個工具欄。我編程用UIImageView添加barbutton項目,因爲它是customView屬性,但是當圖像顯示它是幾乎在屏幕上: enter image description here 圖像是[email protected],是40x40像素,這是我如何將按鈕添加UIBarButtonItem自定義視圖無法正常顯示

UIBarButtonItem *flex1, *flex2; 
UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"[email protected]"]]; 
self.play = [[UIBarButtonItem alloc] initWithCustomView:iv]; 
[self.play setAction:@selector(pauseButtonClicked:)]; 
flex1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; 
flex2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; 
[self.bar setItems:@[flex1, _play, flex2]]; 

Pause.png enter image description here [email protected] enter image description here

+0

在用'initWithCustomView'創建的UIBarButtonItem上調用'setAction:'沒有意義。它不是一個按鈕;它將觸摸處理完全留給自定義視圖。 (關於這一點,文檔非常清楚。) – matt 2013-04-26 23:52:40

回答

0

我是想以後更改工具欄的高度的代碼,去除行固定它。