[英]UITableView,numberOfRowsInSection
I have three data(date, view, textfield).I use SQLite(FMDB).and,It output to tableview. 我有三个数据(日期,视图,文本字段)。我使用SQLite(FMDB).and,它输出到tableview。 When you run this code, the same cell is output in all sections.I want to textfield and view in a cell for each date.I'm beginner,please tell me.
当您运行此代码时,所有部分均输出相同的单元格。我想在每个日期的单元格中进行文本输入和查看。我是初学者,请告诉我。
- (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;
}
Select the right object in the array in the cellForRowAtIndexPath
method: 在
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
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.