0
내 응용 프로그램에서 UITableViewCell
있습니다있는 UITableViewCell의 dealloc 방법
@interface ResultCell : UITableViewCell {
IBOutlet UILabel *name;
IBOutlet UILabel *views;
IBOutlet UILabel *time;
IBOutlet UILabel *rating;
IBOutlet UILabel *artist;
IBOutlet UIImageView *img;
}
@property (nonatomic, retain) UILabel *name;
@property (nonatomic, retain) UILabel *views;
@property (nonatomic, retain) UILabel *time;
@property (nonatomic, retain) UILabel *rating;
@property (nonatomic, retain) UILabel *artist;
@property (nonatomic, retain) UIImageView *img;
@end
그리고 UILabel
....
에 XIB 파일에 연결이 IBOutlet
의 모든이 내가 각 셀을 만드는 방법은 다음과 같습니다
static NSString *CellIdentifier = @"ResultCell";
ResultCell *cell = (ResultCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil){
UIViewController *vc = [[[UIViewController alloc] initWithNibName:@"ResultCell" bundle:nil] autorelease];
cell = (ResultCell *) vc.view;
}
cell.name.text = item.name;
cell.views.text = item.viewCount;
cell.rating.text = [NSString stringWithFormat:@"%d%%",item.rating];
cell.time.text = item.timeStr;
cell.artist.text = item.artist;
그리고 ResultCell
클래스에서 dealoc 메서드를 구현하고을 릴리스해야하는지 알고 싶습니다.? 아니면 내가 한 짓처럼 괜찮은거야? 이전 프로젝트이므로 Non-ARC를 사용하고 있습니다. 당신은 그것이 당신의 dealloc 메소드에서 해제하고 .IT는 메모리 누수를 방지 viewDidUnload
에서 전무를 할당해야을 유지 필요한 경우
왜 e UIViewController를 만든 다음 셀 대신 셀을 가져 옵니까? 귀하의 vc.view는 UIView, 셀이 아닌 것 같습니다. –
이 경우 예를해야합니다. 그러나 어쨌든 superview에 의해 보존 될 것이기 때문에 모든 보유 속성을 갖는 것이 의미없는 것 같습니다. 그들 모두를'할당하다 '로 바꾸지 않겠습니까? 그렇다면'dealloc '을 다룰 필요가 없습니다. – borrrden
왜 ResultCell 클래스 용 UIViewController가 필요합니까? –