이 문제를 해결할 생각이 있습니까? 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 check를 삽입하고 그것을에 전달했다. 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;
}
이제 테이블에 한 행만 표시됩니다. 스크롤하면 행이 변경되지만 한 행만 표시됩니다 ...
문제점 :
어떤 도움이 필요합니까?
덕분에, 당신이 dequeueReusableCellWithIdentifier를 호출이 경우
좋아요, 어떻게 문제를 해결할 수 있습니까 ??? – elp
펜촉을로드하는 코드를 tableView : cellForRowAtIndexPath :로 다시 옮길 수 있습니다. iPad에서 viewDidLoad를 사용하지 않는 경우 BOOL을 저장할 수 있습니다. 그 후 스크롤이 여전히 느린 경우 펜촉으로 만든 셀 대신 Apple에서 만든 것처럼 UITableViewCell의 하위 클래스를 만듭니다. – criscokid
완벽 그리고 루프에 사용할 var에 [[NSBundle mainBundle] loa ...]를 설정하는 방법이 있습니까? – elp