Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

skipday

macrumors newbie
Original poster
Mar 14, 2011
4
0
Hi All,

I was searching a solution for a UITextField in row under UITableView.

Here is what I want to do. UITextField field should be scroll to top when user clicks on it.

I search Google for the issue and did not find any solution.

Can somebody help me how can I implement scrolling event when particular row is selected?

Thank you in advanced.
 
iphone apps development solution

There is no direct event or class for this action. You need to add some custom code as per below guideline.

1) First of all set tag of UITextField as indexpath.row.
2) In UITableView delegate enable or add method "- (BOOL)textFieldShouldBeginEditing: (UITextField *)textField"
3) Pass tag value of UITextField to below method.
4) - (void) setRowOnTop: (NSNumber*)numRow{
NSInteger iRow = [numRow intValue];
CGRect rowFrame = [tiTableView rectForSection:0];
NSIndexPath *indexPath = [[tiTableView indexPathsForRowsInRect:rowFrame] objectAtIndex:iRow];
[tiTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
}
:apple:
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.