Anuradh S Anuradh S - 4 months ago 11
Objective-C Question

why can't I focus on correct uitextfield in the uitableview cell (goes over navigation bar) in iOS, objective c

I'm using a

TableViewController
with custom
TableViweCell
to gather user information. inside my custom
TableViweCell
there are more than 5
textfields
. (NOTE : I'm using tableview controller because it helps scroll above keyboard automatically when tap on uitextfield). so when I tap on first
uitextfield
, automatically focus on it and automatically scroll it to up(stop near the navigation bar bottom line.). then when I tap on another
uitextfield
it scrolls to up with passing the navigation bar.then user has to scroll down to type on it. what is the problem with this.

should I use different custom uitableview cells for each textfield

tableview .m file implementation.

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{

return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

return 1;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
HoteluserdetailformTableViewCell *formcell = [tableView dequeueReusableCellWithIdentifier:@"hotelformcell" forIndexPath:indexPath];


return formcell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return screenSize.height;
}

Answer

Found the solution for this.if we want to use more than one text field we have to return that much of rows in number of rows in section method. ex : if you want 5 text fields

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    return 5;
}

note : use 5 text fields inside the same custom cell does not work for this.