Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios uitableview中带截面的多个原型单元_Ios_Uitableview - Fatal编程技术网

Ios uitableview中带截面的多个原型单元

Ios uitableview中带截面的多个原型单元,ios,uitableview,Ios,Uitableview,我是iOS新手,正在使用uitableview单元。我想以以下方式实现uitableview。 这是一节。 假设数组中有3个条目,那么应该出现3个类似的部分 我使用NSUserDefaults存储数据。 因此,所有数据首先被提取到NSMUtableArray中。数组中的数据存储为,假设UserInfo是我的数组: [“raj”、“test1”、“test2”、“Mon”],----第1行 [“tiya”、“test3”、“test2”、“Tues”],----第二排 [“niha”、“test

我是iOS新手,正在使用uitableview单元。我想以以下方式实现uitableview。

这是一节。 假设数组中有3个条目,那么应该出现3个类似的部分

我使用NSUserDefaults存储数据。 因此,所有数据首先被提取到NSMUtableArray中。数组中的数据存储为,假设UserInfo是我的数组:

[“raj”、“test1”、“test2”、“Mon”],----第1行

[“tiya”、“test3”、“test2”、“Tues”],----第二排

[“niha”、“test1”、“test5”、“Wens”]----第三排

如何使用UITable视图实现上述功能

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  {
    // Return the number of sections.
     return Array.count;
   }

   - (NSInteger)tableView:(UITableView *)tableView   numberOfRowsInSection:(NSInteger)section
     {
          // Return the number of rows in the section.
        return 1;
      }


     - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
       {


     static NSString *CellIdentifier = @"cell";
     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

   UILabel *name = (UILabel*)[cell.contentView viewWithTag:1];
   UILabel *test1 = (UILabel*)[cell.contentView viewWithTag:2];
   UILabel *test2 = (UILabel*)[cell.contentView viewWithTag:3];
   UILabel *day = (UILabel*)[cell.contentView viewWithTag:4];  
     name.text = @"raj";
     test1.text = @"test1";
     test1.text = @"test2";
     day.text = @"Mon";
     return cell;



   }
}

}这里有一点提示:

 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
      {
         return [yourArray count];
      }

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
       {
            for(int i=0; i<[yourArray count];i++)
       {

        if (indexPath.section == i)
        {
                titleForCell=[yourArray objectAtIndex:i]//test i
                descriptionForCell=[yourArray objectAtIndex:i];// time i
        }
            cell.textLabel.text=titleForCell;
            cell.detailTextLabel.text=descriptionForCell;
       }
    return cell;
    }
-(NSInteger)节数表视图:(UITableView*)表视图
{
返回[yourArray count];
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{

对于(int i=0;iI建议您创建一个包含其中所有字段的原型单元格,而不是一个包含单独的测试行、名称行和日期行的部分。我想要一个单独的行,因为在单击每一行时,它应该为ex打开编辑视图。如果用户点击第一行,则点击编辑视图编辑用户名,如果点击第二行,则点击test1编辑v查看打开这是一种更简单的方法。当用户点击一个单元格时,将用户带到一个新的视图控制器,在那里他可以编辑任何特定单元格中包含的信息。在我看来,这将是一种更方便、更恰当的方法。因此,你的意思是,与4个原型单元格不同,应该只有一个原型单元格,其中包含所有选项W什么是cell.name?它是标签的IBOutlet吗?如果是,如何将其连接到IBOutlet,因为如果我尝试连接,则会出现以下错误:从TableViewController到UILabel的lblName出口无效。出口无法连接到重复内容。
else if(indexpath.row==2)
 {
 cell.lbl.text = @"niha";
 cell.lbltest1.text = @"test1";
 cell.lbltest1.text = @"test5";
 cell.lblday.text = @"Wens";
}
 return cell;
 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
      {
         return [yourArray count];
      }

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
       {
            for(int i=0; i<[yourArray count];i++)
       {

        if (indexPath.section == i)
        {
                titleForCell=[yourArray objectAtIndex:i]//test i
                descriptionForCell=[yourArray objectAtIndex:i];// time i
        }
            cell.textLabel.text=titleForCell;
            cell.detailTextLabel.text=descriptionForCell;
       }
    return cell;
    }