开发者

Getting didSelectRowAtIndexpath method called when textfield inside custom table view cell is focused

开发者 https://www.devze.com 2023-03-01 10:00 出处:网络
I have a custom tableviewcell with a label and a textfield. Right now I get callback in method didSelectRowAtIndexpath only when user click开发者_Python百科s on cell outside of my textfield. When I to

I have a custom tableviewcell with a label and a textfield. Right now I get callback in method didSelectRowAtIndexpath only when user click开发者_Python百科s on cell outside of my textfield. When I touch on textfield this method is not called. So what should I do to get that method called when user touches on the textfield.


You want to read into UITextFieldDelegate and more specifically

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField

and

- (void)textFieldDidBeginEditing:(UITextField *)textField

when those get called you can then do this on your UITableView

– selectRowAtIndexPath:animated:scrollPosition:



In cellForRowAtIndexPath method write

cell2.selectionStyle=UITableViewCellSelectionStyleNone;

for that row only

0

精彩评论

暂无评论...
验证码 换一张
取 消