ComCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];为什么总在 ComCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 句报错Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/apple/Library/Application Support/iPhone Simulator/6.0/Applications/0019B49A-11B5-4AE0-AACC-3B941E84F309/SnsXib.app> (loaded)' with name 'Comcell''
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/apple/Library/Application Support/iPhone Simulator/6.0/Applications/0019B49A-11B5-4AE0-AACC-3B941E84F309/SnsXib.app> (loaded)' with name 'Comcell''我不用XIB,直接代码构造UI。背景贴张PNG图片,对着调坐标哇你上面的错误是说,不能在 默认bundle 读取到 你饿XIB文件NIB 就是 XIB。bundle 就是你app 内置路径
{
static NSString *CellIdentifier = @"merge Second Cell";
ILSCMMergeSecondCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[ILSCMMergeSecondCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
}这段代码中ILSCMMergeSecondCell 为自定义的 cell。
我自定义的cell的名字为ComCell.xib,identifier为ComCell然后如你所说,我的代码 static NSString *CellIdentifier = @"ComCell";
ComCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[ComCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
}但是,并没有显示出来?
+ (NSString *)pathForResource:(NSString *)name ofType:(NSString *)ext inDirectory:(NSString *)bundlePath;
+ (NSArray *)pathsForResourcesOfType:(NSString *)ext inDirectory:(NSString *)bundlePath;- (NSString *)pathForResource:(NSString *)name ofType:(NSString *)ext;
当你获取到了cell 的时候,用来代替 上面的alloc 方法,应该就可以显示出来了
不过,建议还是用代码来实现好了- -!XIB,太久没用了,用不来了
BOOL nibRegistered = NO;
if (!nibRegistered) {
UINib *nib = [UINib nibWithNibName:@"Comcell" bundle:nil];
[tableView registerNib:nib forCellReuseIdentifier:CellIdentifier];
nibRegistered = YES;
}
ComCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];为什么总在 ComCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 句报错Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/apple/Library/Application Support/iPhone Simulator/6.0/Applications/0019B49A-11B5-4AE0-AACC-3B941E84F309/SnsXib.app> (loaded)' with name 'Comcell''
公司说不用考虑兼容性,所以就不用xib了,直接在storyboard中写但是还想问问,那个NibName是在哪定义?NibName是文件名吗?比方说 MyNib.xib 它的NibName是不是就是 MyNib?
CGRect transmitViewBounds = CGRectMake(0, 0 , 270, 100);
[cell.subView setBounds:transmitViewBounds];在刚载入时并没有起作用,而是在划出再划入的时候有效果,不过效果却是随机出现在某个cell上请问是怎么回事啊?