0
약 1 시간 동안이 문제로 고생하고 있었고 왜 내 셀이 내 tableview에 나타나지 않는지 이해할 수 없습니다. 튜토리얼을 따라 정확히 언급 한 내용을 수행했습니다. 여전히 문제가 있습니다. 재사용 식별자를 main
으로 설정하면 내 대리자와 데이터 소스가 모두 자체로 설정됩니다. 콘솔에서 오류가 발생하지 않으며 내 데이터가 내 서버에서 전달됩니다. 나는 제목, 설명 등을 인쇄했고 모든 것이 거기에 있었다. 도움말셀이 비어 있습니다.
#import "HTTPService.h"
#import "ViewController.h"
#import "VideoCell.h"
#import "Video.h"
@interface ViewController()
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic,strong) NSArray *videoList;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.dataSource = self;
self.tableView.delegate = self;
self.videoList = [[NSArray alloc]init];
[[HTTPService instance]getTutorials:^(NSArray * _Nullable
dataArray, NSString * _Nullable errMessage)
{
if(dataArray){
NSMutableArray *arr = [[NSMutableArray alloc]init];
for (NSDictionary *d in dataArray){
Video *vid = [[Video alloc]init];
vid.videoTitle = [d objectForKey:@"title"];
vid.videoDescription = [d objectForKey:@"description"];
vid.thumbnailURL = [d objectForKey:@"thumbnail"];
vid.videoIFrame = [d objectForKey:@"iframe"];
[arr addObject:vid];
}
self.videoList = arr;
[self updateTableData];
}
else if(errMessage)
NSLog(@"Alert to user: %@",errMessage);
}];
}
-(void) updateTableData{
dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView reloadData];
});
}
- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView
cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
VideoCell *vCell = (VideoCell*)[tableView
dequeueReusableCellWithIdentifier:@"main"];
if(!vCell)
vCell = [[VideoCell alloc]init];
NSLog(@"here heree");
return vCell;
}
- (NSInteger)tableView:(nonnull UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
NSLog(@"hererrrr");
return self.videoList.count;
}
-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:
(nonnull NSIndexPath *)indexPath{
}
-(void)tableView:(UITableView*)tableView willDisplayCell:(nonnull
UITableViewCell *)cell forRowAtIndexPath:(nonnull NSIndexPath
*)indexPath{
NSLog(@"Im in this bitch");
Video *vid = [self.videoList objectAtIndex:indexPath.row];
VideoCell *vidCell = (VideoCell*)cell;
[vidCell updateUI:vid];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
@end
가져 오기 파일이 필요한지 알려주세요. 한 가지를 제외하고
스토리 보드 또는 NIB에 'tableView' 콘센트를 연결 했습니까? –
관용적 인 일은'willDisplayCell'보다는'cellForRow :'에 셀을 설정하는 것입니다. 'willDisplayCell :'에 중단 점을 놓습니다. 스토리 보드를 콘센트에 연결 했습니까? – dannyzlo
@MatusalemMarques 나는 그렇게 믿는다! 방금 추가 한 이미지를 확인하십시오. – humbleCoder