0
UITableView를 구현하는보기가 있습니다. NSMutableArray 전달할 수있는 setData라는 메서드가 있습니다. 이 작업을 수행하면 [self reloadData]가 호출됩니다. 필자는 일단 배열을 확인하고 테이블 셀을 설정하는 모든 함수를 호출하면이를 이해하게됩니다.UITableView에서 reloadData를 호출하면 표 셀이 채워지지 않는 것 같습니다.
일부 로그 문을 넣었고 중단 점 설정을 시도했지만 해당 코드가 전혀 호출되지 않았습니다. 내가 뭘 잘못하고 있는지 궁금해.
여기에 내 .m 코드가 있습니다.
#import "JornadaKMLList.h"
@implementation JornadaKMLList
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
-(void)setData:(NSMutableArray*)value
{
collection = value;
[self reloadData];
}
//table view stuff
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
NSLog(@"this is line 33");
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSLog(@"this is line 39");
return [collection count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"this is line 43");
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] ;
}
// Configure the cell...
KmlVO *vo = [collection objectAtIndex:indexPath.row];
cell.textLabel.text = vo->title;
return cell;
}
@end
그리고 여기 내 .H 코드
당신은 당신이 사용하고있는UITableView
서브 클래스가되도록
UITableView
의
datasource
및
delegate
속성을 설정해야합니다
#import <UIKit/UIKit.h>
#import "JornadaKMLList.h"
#import "KmlVO.h"
@interface JornadaKMLList : UITableView <UITableViewDelegate,UITableViewDataSource>
{
NSMutableArray *collection;
}
-(void)setData:(NSMutableArray*)value;
@end