0
我試圖製作一個音頻播放器,並在底部有一個工具欄。我編程用UIImageView
添加barbutton項目,因爲它是customView
屬性,但是當圖像顯示它是幾乎在屏幕上: 圖像是[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
[email protected]
在用'initWithCustomView'創建的UIBarButtonItem上調用'setAction:'沒有意義。它不是一個按鈕;它將觸摸處理完全留給自定義視圖。 (關於這一點,文檔非常清楚。) – matt 2013-04-26 23:52:40