0
我想把標籤放在UIBarButtonItem中。這裏是我的viewDidLoad方法:如何爲UIBarButtonItem設置自定義視圖?
characterCountLabel = [[UILabel alloc] init];
characterCountLabel.text = @"HELLO";
charCountButton = [[UIBarButtonItem alloc]initWithCustomView:characterCountLabel];
一切都正確地連接在IB。爲什麼標籤不出現在我的UIBarButtonItem中?
我在IB有一個UIToolBar。我添加了一個UIBarButtonItem到IB – 2010-07-26 17:48:48
的工具欄所以你想添加一個UILabel到你在IB中創建的UIBarButtonItem?我不認爲有什麼方法可以在UIBarButtonItem創建後設置自定義視圖參數。它只在init中完成,所以如果你有一個項目在IB中連接到charCountButton,你可能會遇到問題。我會斷開連接並在代碼中完成所有操作。 – 2010-07-26 18:00:22