この問題を解決するアイデアはありますか? cellForRowAtIndexPathとNSBundle mainBundleの問題
この
はrespectly 正しいと間違った方法です:この作業をされているコード:
- (UITableViewCell *)[...] cellForRowAtIndexPath:(NSIndexPath *)indexPath {
@try {
newsRow = ((NewsRowController *)[tableView dequeueReusableCellWithIdentifier:@"cell"]);
if (newsRow == nil) {
if ([[Device GetModel] isEqualToString:@"iPad Simulator"] ||
[[Device GetModel] isEqualToString:@"iPad"])
[[NSBundle mainBundle] loadNibNamed:@"NewsRow_ipad" owner:self options:nil];
else [[NSBundle mainBundle] loadNibNamed:@"NewsRow" owner:self options:nil];
if ([tableArray count] > 0)
[newsRow setData:[tableArray objectAtIndex:indexPath.row]];
}
}
@catch (NSException * e) {
NSLog(@"a!!!!!");
}
return newsRow;
}
...しかし、理由は私の3Gデバイスで、それはだゆっくり私はテーブルを上下にスクロールします私はこの方法でコードを変更し、viewDidLoadのDeviceチェックを挿入してに渡しました10:
NSArray *cRow;
@property (nonatomic, retain) NSArray *cRow;
[...]
@syntetize cRow;
- (void)viewDidLoad {
[...]
if ([[Device GetModel] isEqualToString:@"iPad Simulator"]
||
[[Device GetModel] isEqualToString:@"iPad"])
cRow = [[[NSBundle mainBundle] loadNibNamed:@"NewsRow_ipad" owner:self options:nil] retain];
else cRow = [[[NSBundle mainBundle] loadNibNamed:@"NewsRow" owner:self options:nil] retain];
[...]
}
- (UITableViewCell *)[...] cellForRowAtIndexPath:(NSIndexPath *)indexPath {
@try {
newsRow = ((NewsRowController *)[tableView dequeueReusableCellWithIdentifier:@"cell"]);
if (newsRow == nil) {
//
// ADDED CODE.
//
newsRow = [cRow objectAtIndex:0];
//
if ([tableArray count] > 0)
[newsRow setData:[tableArray objectAtIndex:indexPath.row]];
}
}
@catch (NSException * e) {
NSLog(@"a!!!!!");
}
return newsRow;
}
ここでは、テーブルには1行しか表示されません。スクロールすると行が変わりますが、行が1行しか表示されません...
問題が何ですか?
助けてください?
おかげで、あなたはdequeueReusableCellWithIdentifierを呼び出すこの場合
ok、どうすれば問題を解決できますか? – elp
ペン先を読み込むコードのtableView:cellForRowAtIndexPath:への移動を開始することができます。iPadのviewDidLoadを使用していない場合のBOOLを格納できます。スクロールがまだ遅い場合、ペンで作成されたセルの代わりに、アップルのようにUITableViewCellの独自のサブクラスを作成します。 – criscokid
が完璧です。ループ内で使うには、[[NSBundle mainBundle] loa ...]をvarに設定する方法がありますか? – elp