xmartlabs / XLForm

XLForm is the most flexible and powerful iOS library to create dynamic table-view forms. Fully compatible with Swift & Obj-C.
MIT License
5.78k stars 953 forks source link

Get and set value of current uitextview #532

Closed focusedonfit closed 8 years ago

focusedonfit commented 9 years ago

I have a custom input accessory view that I want to get the current text in the UITextView and then change it as well. What is the best way to accomplish this?

Thank you

mojidabckuu commented 9 years ago

@focusedonfit When user taps on UITextView in your view controller(XLFormViewController instance) will be called inputAccessoryViewForRowDescriptor: method. In this method you can check the tag of your rowDescriptor instance and return view that you need. Don't forget to return [super inputAccessoryViewForRowDescriptor:rowDescriptor]; to save base inputAccessoryView for other cells.

focusedonfit commented 9 years ago

I can set the view of my inputAccessory OK. But I'm trying to hook up the buttons in the view. For example, I have a button that I want to add '5' to whatever number is currently in the textview.

mojidabckuu commented 9 years ago

@focusedonfit You can get current 'responder' of your form and do whatever you want using '[self.tableView findFirstResponder]'. In this case you can add button to 'inputAccessoryView' and as action get responder cell, set/update/add value of 'rowDescriptor' call '- (void)update' method of cell to flush changes in UI.