私が使用しているものには奇妙な問題があります。カスタムtableViewCellまたはdb。私のアプリでは、UITableViewCellのサブクラス化を行いました。私のサブビューは透明ではないので、スクロールの問題や生産性への影響はないはずです。彼らはうまく見えますが、問題は、10個の最初のセルしか見ることができないということです。データベースから右のIDをフェッチしている間に、同じ名前のNAMEラベルやその他のものを繰り返した後に繰り返します。10個のCustomViewCellだけが正しく生成されています
CATのID = 12 >> DOGのID = 18
そしてCATの代わりにはDOGべきであるように見えます。 CATセルをクリックすると、私は犬のタイトルを取得しています。だから、viewCellのラベルは軽いです。
SQLiteStudioで同じdb selectを実行しようとしましたが、問題ありません。私はレコードの完全なセットを取得しています。誰かが同じ問題に直面したのか、悪いのはどこですか?
DBACCESS方法:
-(NSMutableArray*)getNominals:(int)subCountryID
{
NSMutableArray *nominals=[[[NSMutableArray alloc]init]autorelease];
const char* sqlNominals=sqlite3_mprintf("SELECT noms.nominalID, noms.nominal,noms.nominalName,noms.nominalImg,noms.priority\
FROM nominals AS noms\
INNER JOIN NominalsAndSubCountriesRelation as rel\
ON noms.nominalID=rel.NominalID\
WHERE rel.SubcountruID=%i\
ORDER BY noms.priority",subCountryID);
sqlite3_stmt *statement;
int sqlResult = sqlite3_prepare_v2(database, sqlNominals, -1, &statement, NULL);
if (sqlResult== SQLITE_OK)
{
while (sqlite3_step(statement) == SQLITE_ROW)
{
Nominal *nom=[[Nominal alloc]init];
nom.nominalID=sqlite3_column_int(statement, 0);
char *nominal=(char *)sqlite3_column_text(statement, 1);
char *nominalName=(char*)sqlite3_column_text(statement, 2);
char *nominalImg=(char*)sqlite3_column_text(statement, 3);
nom.nominal=(nominal)?[NSString stringWithUTF8String:nominal]: @"";
nom.nominalName=(nominalName)?[NSString stringWithUTF8String:nominalName]: @"";
nom.nominalImg=(nominalImg)?[NSString stringWithUTF8String:nominalImg]: @"";
[nominals addObject:nom];
[nom release];
}
sqlite3_finalize(statement);
}
else
{
[self dbConnectionError];
}
return nominals;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.nominalsArr count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
NominalsCustomCell *cell =(NominalsCustomCell*)[self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[NominalsCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
Nominal *nominalsObj=[self.nominalsArr objectAtIndex:[indexPath row]];
[cell setTheNominals:nominalsObj];
}
return cell;
}
は、事前にありがとうございます。セルが設定されるたびに、新しい又は再使用1つが、それは関係なく、設定されなければならないので
悪はあなたのcellForRowAtIndexPathメソッドにあります。あなたの質問にそれを加えてください。 – jrturton
'UITableViewDataSource'メソッドからコードを投稿してください。 –
@jrturton私はそれについても考えましたが、この方法では問題が見つかりませんでした。論理的に考えると正しいです。このような問題は、通常、cellForRowAtIndexPathメソッドのエラーのために発生します。 – NCFUSN