0
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:@"cell"];
if (cell == nil) {
cell = [[[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"] autorelease];
}
int theRow = indexPath.row;
if(indexPath.section == 0) theRow += 0;
if(indexPath.section == 1) theRow += 3;
if(indexPath.section == 2) theRow += 7;
CountriesAppDelegate *appDelegate = (CountriesAppDelegate *)[[UIApplication sharedApplication] delegate];
CountriesData *country = (CountriesData *)[appDelegate.countries objectAtIndex:indexPath.row];
[[cell primaryLabel] setText:country.countryName];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
UITableView
をsqliteデータベースから埋めます。私は3つのセクションを持っています。データベースからUITableViewを書き込む
上記のコードの場合、各セクションはデータベースの最初の要素から始まります。
しかし、私は、可変部分theRow
(3つの要素、4つの要素、他の要素)としてdatebase要素で満たされた各セクションが必要です。
アイデア?
は、使用してappDelegate.countries' 'から' theRow'の値が、グラブの値を計算 'indexPath.row' ... –
あなたはこの' CountriesData *国=(CountriesData *)[appDelegateのようなものを意味します。国オブジェクトobjectIndex:indexPath.theRow]; '? – RomanHouse
CountriesData * country =(CountriesData *)[appDelegate.countries objectAtIndex:theRow];あなたの問題は解決しました –