János
János

Reputation: 35060

Is it a was to select section in UITableView and add row for it?

I do not think is possible but is it a way to select a particular section in UITableView? I would like to make it possible for user to add a row to that section.

The problem that section normaly has a 22px height, so it is too small to select it, and there is no such a delegate method.

Upvotes: 0

Views: 463

Answers (2)

ChintaN -Maddy- Ramani
ChintaN -Maddy- Ramani

Reputation: 5164

Can not understand your question correctly but you can use tableview default method to insert row at specific Section and Row using insertRowsAtIndexPaths method shown below.

Add UITapGestureRecognizer on your headerview which you have created using viewForHeaderInSection and set tag = section like yourView.tag = section; and in your tapGestureSelected method.

-(void)tapGestRec:(UIGestureRecognizer *)gest
{
    // Here you will know which section is tapped using gest.view.tag
    NSLog(@"You have selected : %d Section",gest.view.tag);
    [yourTableView insertRowsAtIndexPaths:@[[NSIndexPath indexPathForItem:0 inSection:gest.view.tag]] withRowAnimation:UITableViewRowAnimationAutomatic];
}

Upvotes: 0

gvuksic
gvuksic

Reputation: 3013

I believe you are trying to use section header, there is no such method, but you can add UIButton or UITapGestureRecognizer to section header view and that you can insert row to that section. Use method:

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section

Upvotes: 1

Related Questions