开发者

objective-c: How to access textfield in first row of second section of Tableview?

I have a Tableview I want to change the value of textField on the first row of second section?

I assign it tag value which lets say is 2.

Now how to access that T开发者_开发百科extField with tag.


Give a tag to that text field and by using that tag you can change the value.

UITextField *tempField = (UITextField *) [self.view viewWithTag: tag]; 

tempField.text = @"Your data"; 


If you wnat to access your textField inside some table view methods so you can do this:-

UITextField *tView=(UITextField *)[cell.contentView viewWithTag:2];

If you have to access your textField outside some tableVIew method than you have to do :-

lastSelectedPath=indexPath;do where you have added your text field.You will need its indexPath.Make it a global variable.

UITableViewCell *prevoiusCell=(UITableViewCell *)[*yourtabelviewname* cellForRowAtIndexPath:lastSelectedPath];
UITextField *tView=(UITextField *)[prevoiusCell.contentView viewWithTag:2];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜