我遇到了一个恼人的问题,我不能为我的生活发现。我知道这已被覆盖,据我所知,我做的一切正确,但我不能让这个自定义单元显示在模拟器上。自定义tableviewcell.xib不填充tableview
我这个问题的表视图和集合视图,以及我的结果可以看到两个相同的方式,所以如果你可以帮助我与表视图它将不胜感激。这里有:
以下代码来自View Controller的.m文件,您可以在viewdidload方法中看到,我注册了nib并给出了重用标识符'tableViewCell'。现在纠正我,如果我错了,但我相信我应该把这个标识符给故事板的原型单元格,并留下xib的重用标识符为空。换句话说,我应该使用'tableViewCell'标识符的唯一地方是原型单元格,viewdidload方法和cellforRowAtIndexPath方法,对吗?请让我知道如果我错过了任何步骤,请提前致谢:
#import "headEndChassisViewController.h"
#import "HeadEndChassisTableViewCell.h"
@interface headEndChassisViewController()
@end
@implementation headEndChassisViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
UINib *cellNib = [UINib nibWithNibName:@"headEndChassisCollectionViewCell" bundle:nil];
[self.headEndChassisCollectionView registerNib:cellNib forCellWithReuseIdentifier:@"headEndCell"];
UINib *tableViewCellNib = [UINib nibWithNibName:@"HeadEndChassisTableViewCell" bundle:nil];
[self.headEndChassisTableView registerNib:tableViewCellNib forCellReuseIdentifier:@"tableViewCell"];
//The code below configures the textviews underneath the CollectionView
[[self.slotNumberTextView layer] setBorderColor:[[UIColor blackColor] CGColor]];
[[self.slotNumberTextView layer] setBorderWidth:1];
[[self.slotNumberTextView layer] setCornerRadius:1];
self.slotNumberTextView.editable = NO;
[[self.slotStatusTextView layer] setBorderColor:[[UIColor blackColor] CGColor]];
[[self.slotStatusTextView layer] setBorderWidth:1];
[[self.slotStatusTextView layer] setCornerRadius:1];
self.slotStatusTextView.editable = NO;
[[self.bandTextView layer] setBorderColor:[[UIColor blackColor] CGColor]];
[[self.bandTextView layer] setBorderWidth:1];
[[self.bandTextView layer] setCornerRadius:1];
self.bandTextView.editable = NO;
[[self.typeTextView layer] setBorderColor:[[UIColor blackColor] CGColor]];
[[self.typeTextView layer] setBorderWidth:1];
[[self.typeTextView layer] setCornerRadius:1];
self.typeTextView.editable = NO;
//Code below configures the input power textview corner radius
[[self.inputPowerTextView layer] setCornerRadius:3.3];
//Code below configures border for Apply and Reset Buttons
[[_resetButtonProperty layer]setBorderWidth:1.0f];
[[_applyButtonProperty layer]setBorderWidth:1.0f];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
#pragma mark - Collection View
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return 12;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"headEndCell" forIndexPath:indexPath];
cell.backgroundColor = [UIColor whiteColor];
return cell;
}
#pragma mark - Table View
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 8;
}
-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"tableViewCell" forIndexPath:indexPath];
cell.backgroundColor = [UIColor whiteColor];
return cell;
}
- (IBAction)resetButton:(id)sender {
}
- (IBAction)applyButton:(id)sender {
}
@end
'cellNib'最终是否为零?如果这样做意味着它找不到你的笔尖。 xib中的单元格是“UITableViewCell”的子类吗?如果不是,那么它将无法将其出队。 xib'tableViewCell'中的重用标识符是否相同?如果不是,它将无法将其出队。 – InkGolem 2015-02-11 23:46:18