Need iphone apps Development Help

Discussion in 'iPhone Tips, Help and Troubleshooting' started by skipday, Mar 15, 2011.

  1. skipday macrumors newbie

    Mar 14, 2011
    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.
  2. baharharre, Mar 18, 2011
    Last edited: Apr 21, 2011

    baharharre macrumors newbie

    Mar 16, 2011
    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];
  3. skipday thread starter macrumors newbie

    Mar 14, 2011

Share This Page