Ios 全部选择、全部取消选择和在自定义表格视图中选择特定单元格

Ios 全部选择、全部取消选择和在自定义表格视图中选择特定单元格,ios,iphone,objective-c,drop-down-menu,ios7,Ios,Iphone,Objective C,Drop Down Menu,Ios7,我使用表格单元格创建了一个下拉列表,在这里我显示了我的数据。我的数据是在下拉列表中显示的。现在我想所有的单元格都应该首先被选中。我还想取消选择所有单元格和单个单元格 (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if ([tableView isEqual:expansionTableView]) { forState:UIControlSta

我使用表格单元格创建了一个下拉列表,在这里我显示了我的数据。我的数据是在下拉列表中显示的。现在我想所有的单元格都应该首先被选中。我还想取消选择所有单元格和单个单元格

(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([tableView isEqual:expansionTableView]) {

   forState:UIControlStateNormal];

    if (indexPath.row == 0) {
        if ([indexPath isEqual:self.selectIndex]) {
            self.isOpen = NO;
            [self didSelectCellRowFirstDo:NO nextDo:NO];
            self.selectIndex = nil;

        }else
        {
            if (!self.selectIndex) {
                self.selectIndex = indexPath;
                [self didSelectCellRowFirstDo:YES nextDo:NO];


            }else
            {

                [self didSelectCellRowFirstDo:NO nextDo:YES];
            }
        }

    }else
    {
        objectForKey:@"surveyName"];


        NSMutableArray *list=[[NSMutableArray alloc]init];
        NSMutableArray *idlist =[[NSMutableArray alloc]init];
        for (int i=0; i<_arraySurveyName.count; i++) {
            NSMutableDictionary *dict=[_arraySurveyName objectAtIndex:i];
            NSString *surveyName=[dict valueForKey:@"SurveyName"];
            NSString *surveyID =[dict valueForKey:@"SurveyId"];
            [list addObject:surveyName];
            [idlist addObject:surveyID];

        }
        NSString *item = [list objectAtIndex:indexPath.row-1];
       NSNumber *item1= [idlist objectAtIndex:indexPath.row-1];
        str = item1;
        NSLog(@"%@",str);
        [_btn_surveyName setTitle:item forState:UIControlStateNormal];

        [expansionTableView setHidden:YES];

    }

}
else if ([tableView isEqual:expansionTableViewQtn]){
                NSString *selectedQuestion=[arrayOfQuestionDetail objectAtIndex:indexPath.section];
                [expansionTableViewQtn setHidden:YES];
                [_btn_showQuestn setTitle:selectedQuestion forState:UIControlStateNormal];
    }
}
(void)tableView:(UITableView*)tableView DidSelectRowatineXpath:(NSIndexPath*)indexPath
{
if([tableView isEqual:expansionTableView]){
forState:uicontrol状态正常];
if(indexPath.row==0){
if([indexath isEqual:self.selectIndex]){
self.isOpen=否;
[self-didSelectCellRowFirstDo:NO nextDo:NO];
self.selectIndex=nil;
}否则
{
如果(!self.selectIndex){
self.selectIndex=indexPath;
[self-didSelectCellRowFirstDo:是下一步DO:否];
}否则
{
[self-didSelectCellRowFirstDo:否下一步DO:是];
}
}
}否则
{
objectForKey:@“surveyName”];
NSMUTABLEARRY*list=[[NSMUTABLEARRY alloc]init];
NSMutableArray*idlist=[[NSMutableArray alloc]init];

对于(int i=0;i,您可以使用以下方法来选择和取消选择单元格

- (void)selectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(UITableViewScrollPosition)scrollPosition;
- (void)deselectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated;

[tableView deselectRowAtIndexPath:indexPath animated:NO];//For deselecting
[tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];//For selecting