How to set editing is yes for a particular section in iPhone
- by Madan Mohan
Hi guys,
I have declared UITableView in .h file.I have 5 section in the table view, now I need to set the tableview.editing= yes only for section 4.
how can I dispaly the + button beside section 4 and all other sections must in editing = NO.
myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0,0,320,415) style:UITableViewStyleGrouped];
myTableView.delegate = self;
myTableView.dataSource=self;
[myTableView setSectionFooterHeight:0];
[myTableView setSectionHeaderHeight:15];
[myTableView setSeparatorColor:[UIColor lightGrayColor]];
myTableView.backgroundColor = [UIColor colorWithRed:0.85546875 green:0.8828125 blue:0.92578125 alpha:1];
[myView addSubview: myTableView];
I tried like this it is not working.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if(section==0)
{
myTableView.editing = NO;
myTableView.allowsSelectionDuringEditing = NO;
return 3;
}
else if(section ==1)
{
myTableView.editing = NO;
myTableView.allowsSelectionDuringEditing = NO;
return 2;
}
else if(section==4)
{
myTableView.editing = YES;
myTableView.allowsSelectionDuringEditing = YES;
if(isEdit == YES)
{
if([editObject.contactList count]0)
{
return [editObject.contactList count]+1;
}
else
{
return 1;
}
}
else if(isEdit == NO)
{
if([addContactList count]0)
{
return [addContactList count]+1;
}
else
{
return 1;
}
}
}
else if(section==2)
{
myTableView.editing = NO;
myTableView.allowsSelectionDuringEditing = NO;
return 1;
}
else if(section==3)
{
myTableView.editing = NO;
myTableView.allowsSelectionDuringEditing = NO;
return 1;
}
return 0;
}
I am getting + button to the 4th section but all other section are moved to the right side.
please help me
Thank You,
Madan Avulagadda.