我是新來的Xcode試圖顯示一些數據在tableview中使用自定義單元格獲得*** Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:]
,錯誤。請任何人都可以指導我。提前致謝。我正在使用storyboard來創建UITableview。聲明失敗 - [UITableView _configureCellForDisplay:forIndexPath:],
這裏是我的Viewcontroller.m代碼
#import "ViewController.h"
#import "CustomCell.h"
@interface ViewController()
{
NSArray *profilehd;
NSArray *profileimg;
}
@end
@implementation ViewController
@synthesis tableview;
-(void)viewDidLoad
{
tablevw.dataSource = self;
tablevw.delegate = self;
profilehd = [[NSArray alloc]initWithObjects:@"Name",@"Email",@"Skype", nil];
profileimg = [[NSArray alloc]initWithObjects:@"about_me_icon.png",@"email_icon.png",@"skype_icon.png", nil];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
#pragma mark:-UITableView Datasource and Delegate Methods
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [profilehd count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"CellID";
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil)
{
cell.ProfilehdLabel.text = [profilehd objectAtIndex:indexPath.row];
cell.profileImgvw.image = [UIImage imageNamed:[profileimg objectAtIndex:indexPath.row]];
}
return cell;
}
CustomCell.m
@property (strong, nonatomic) IBOutlet UILabel *profilehdLabel;
@property (strong, nonatomic) IBOutlet UIImageView *profileImgvw;
我認爲你應該編輯你的問題的代碼部分的格式。 – jogo