일반적으로 테이블뷰를 사용할때 아래 코드를 사용한다.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIndentifier = @"ExampleCell"; UITableViewCell *cell = [tableViewdequeueReusableCellWithIdentifier: cellIndentifier]; if(cell == nil) { NSArray *bundleObjects = [[NSBundle mainBundle]loadNibNamed: cellIndentifier owner:nil options:nil]; cell = [bundleObjects lastObject]; } return cell; }위 코드중에 dequeueReusableCellWithIdentifier 라는 함수가 있는데,Identifier 를 지정해주고, xib 파일에서 Identifier 도 지정해주었는데,디버그를 걸어보면 cell 이 계속 nil 이 되면서 xib 파일을 계속 불러온다.아무리 구글링해보고, 예제 코드 따라해보아도 안됨 ㅠㅠ.할수없이 storyboard 에서 uitableview 에 customcell 을 드래그 해서 넣어주고, Identifier 를 지정해주니cell 재사용이 됨.
'Computer > iOS' 카테고리의 다른 글
performSelectorOnMainThread implicit conversion of 'int' to 'id' is disallowed with arc (0) | 2014.12.17 |
---|