테스트하기 위해 코드를 간소화했으며 여전히 전화로 내 메모리 사용량이 테이블의 속도가 느려지는 지점까지 올라간다.왜 테이블 셀이 출시되지 않습니까?
누군가 내가 여기서 잘못하고있는 것을 말해 줄 수 있습니까?
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 40;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 100;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellID = @"Cell";
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellID];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:cellID] autorelease];
}
UILabel *l=[[UILabel alloc] initWithFrame:CGRectMake(10,10,300,16)];
l.font=[UIFont boldSystemFontOfSize:15];
l.textColor=[UIColor whiteColor];
l.backgroundColor=[UIColor blackColor];
[email protected]"Just some randoom text here";
[cell.contentView addSubview:l];
[l release];
아차 . 코드 붙여 넣기가 너무 잘 작동하지 않았습니다. 여기에 바로 붙여 넣기입니다 :
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 40;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 100;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellID = @"Cell";
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellID];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:cellID] autorelease];
}
UILabel *l=[[UILabel alloc] initWithFrame:CGRectMake(10,10,300,16)];
l.font=[UIFont boldSystemFontOfSize:15];
l.textColor=[UIColor whiteColor];
l.backgroundColor=[UIColor blackColor];
[email protected]"Just some randoom text here";
[cell.contentView addSubview:l];
[l release];
return cell;
}
불행히도이 솔루션을 사용하면 메모리가 고정됩니다 (직선 복사 및 붙여 넣기). 아마도 테이블 뷰가 배치되는 방식 일 수 있습니다. IB에서 tabbar 컨트롤러를 생성하고 IB에서 뷰 컨트롤러도 할당합니다. 그래서 자동 응답 풀이 절대로 출시 될 기회가 없습니까? 더 좋은 방법은 무엇일까요? 그리고 NSAutoreleasePool을 메인이 아닌 다른 곳에 설치해야합니까? 그렇다면,보기 자체가 탭바 위치에있는 것이 해제되지 않는다면? –
이것이 무엇인지는 모르지만 시뮬레이터에서 메모리가 올바르게 해제됩니다. –
모든 UI 이벤트 후에 풀이 소모됩니다. 정확히 * 출시되지 않은 것은 무엇입니까? 즉 언제 메모리가 소모되는 걸까요? 긴 항목 목록을 스크롤 한 다음 viewcontroller에서 다시 빠져 나올 때입니까? 다른 곳에서는 누수가 있습니다. – Jason