ios resignFirstResponder of UITextView in cell from accessory toolbar -


i trying edit uitextview inside cell keyboard preserves 'return' key line break & adds 'cancel' & 'done' button in accessory toolbar. looks fine 'sender' parameter in selector pointing uibarbuttonitem , not uitextview in cell program breaks error. how tell selected cell's uitextview resignfirstresponder?

// cell accessory toolbar     if (!cell) {         [tableview registernib: [uinib nibwithnibname:@"customcell" bundle:nil] forcellreuseidentifier:@"customcell"];         cell = [tableview dequeuereusablecellwithidentifier:@"customcell"];         [cell.textview setdelegate:self];          uitoolbar* toolbar = [[uitoolbar alloc]initwithframe:cgrectmake(0, 0, 320, 50)];         toolbar.barstyle = uibarstyleblacktranslucent;         toolbar.items = [nsarray arraywithobjects:                        [[uibarbuttonitem alloc]initwithtitle:@"cancel" style:uibarbuttonitemstylebordered     target:self action:@selector(toolbarcancel:)],                        [[uibarbuttonitem alloc]initwithbarbuttonsystemitem:uibarbuttonsystemitemflexiblespace target:nil action:nil],                        [[uibarbuttonitem alloc]initwithtitle:@"done" style:uibarbuttonitemstyledone target:self action:@selector(toolbardone:)],                        nil];         [toolbar sizetofit];         cell.textview.inputaccessoryview = toolbar;  // selector - (ibaction) toolbardone:(id)sender {     [sender resignfirstresponder]; } 

self.view.endediting(true) 

or

[self.view endeditiing:yes]; 

from apple's docs:

this method looks @ current view , subview hierarchy text field first responder. if finds one, asks text field resign first responder. if force parameter set yes, text field never asked; forced resign.

this goto function making keyboard drop, no matter view brought up.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -