创建后,在UITextView的inputAccessoryView中更改UIBarButtonItem的按钮标题?

时间:2015-07-07 05:29:51

标签: swift uibarbuttonitem inputaccessoryview

我在inputAccessoryView中为UITextView创建了viewDidLoad

var keyBoardToolBar:UIToolbar = UIToolbar(frame:CGRectMake(0,0,self.view.frame.size.width,50))     keyBoardToolBar.barStyle = UIBarStyle.Default

var firstButton: UIBarButtonItem = UIBarButtonItem(title: "firstButton", style: UIBarButtonItemStyle.Plain, target: self, action: Selector("firstButtonAction"))

var flexSpace = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FlexibleSpace, target: nil, action: nil)

var done: UIBarButtonItem = UIBarButtonItem(title: "Done", style: UIBarButtonItemStyle.Done, target: self, action: Selector("doneButtonAction"))

var items = NSMutableArray()

items.addObject(firstButton)
items.addObject(flexSpace)
items.addObject(done)

keyBoardToolBar.items = items as [AnyObject]
keyBoardToolBar.sizeToFit()

self.tv.inputAccessoryView = keyBoardToolBar

我想更改其他功能中的firstButton按钮文字(viewDidLoad之后)。那我该怎么办?谢谢!

1 个答案:

答案 0 :(得分:0)

var firstButton: UIBarButtonItem就在viewDidLoad之前的课堂内,并更改其标题使用firstButton.title。 :)