Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/117.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
Iphone UITable视图,第节中的行数_Iphone_Ios_Xcode - Fatal编程技术网

Iphone UITable视图,第节中的行数

Iphone UITable视图,第节中的行数,iphone,ios,xcode,Iphone,Ios,Xcode,我有三个数据(日期、视图、文本字段)。我使用SQLite(FMDB)。并且,它输出到tableview。 当你运行这段代码时,所有部分都会输出相同的单元格。我想在单元格中查看每个日期的文本字段。我是初学者,请告诉我 - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; titleArry = [[NSMutableArray alloc] init ]; //タイトルを格納するための可変

我有三个数据(日期、视图、文本字段)。我使用SQLite(FMDB)。并且,它输出到tableview。 当你运行这段代码时,所有部分都会输出相同的单元格。我想在单元格中查看每个日期的文本字段。我是初学者,请告诉我

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    titleArry = [[NSMutableArray alloc] init ]; //タイトルを格納するための可変配列
    dateArray = [[NSMutableArray alloc] init ]; // 日付格納する可変配列
    contentsArry = [[NSMutableArray alloc] init ]; //画像を格納するための可変配列


    [DataModel selectTitle:titleArry];
    [DataModel selectDateTitle:dateArray]; 
    [DataModel selectContents:contentsArry];

    NSMutableSet *mutableSet = [NSMutableSet setWithArray:dateArray]; // 日付の重複を取り除く
    array = [mutableSet allObjects];

    [table reloadData];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return array.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return  contentsArry.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] ;
    }

    //セルに表示する内容
    cell.textLabel.text = [titleArry objectAtIndex:indexPath.row];
    cell.imageView.image = [[UIImage alloc] initWithData:[contentsArry objectAtIndex:indexPath.row]];

    return cell;
}

查看在
cellForRowAtIndexPath
方法中选择数组中的正确对象:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    //get the right object (use the object that is in the array, this is just an example)
    NSObject *object = [array objectAtIndex:indexPath];
    cell.textLabel.text = object.title
}