TableViewCell指定 xib文件 调试
来源:互联网 发布:java web中javamail 编辑:程序博客网 时间:2024/05/18 12:04
今天在调试 cell 用 xib 文件的时候发现,调试了很长时间 发现 在 6 之上时可以用,在 6之下时不可以用会报错
使用:
static NSString *CellIndentifier = @"RightTableViewCell";
/ RightTableViewCell *cell = (RightTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIndentifier];
//
// static NSString *CellIndentifier = @"RightTableViewCell";
// RightTableViewCell *cell = (RightTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIndentifier];
//
// if (cell == nil) {
// cell = [[[RightTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIndentifier] autorelease];
// }
在6.1上可以用,在6之下发现之下错误:
经过调试 使用
static NSString *CellIndentifier = @"RightTableViewCell";
RightTableViewCell *cell = (RightTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIndentifier];
if(cell==nil)
{
NSArray *nibsArray=[[NSBundle mainBundle] loadNibNamed:@"RightTableViewCell" owner:self options:nil];
cell=(RightTableViewCell*)[nibsArray objectAtIndex:0];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIndentifier = @"RightTableViewCell";
RightTableViewCell *cell = (RightTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIndentifier];
if(cell==nil)
{
NSArray *nibsArray=[[NSBundle mainBundle] loadNibNamed:@"RightTableViewCell" owner:self options:nil];
cell=(RightTableViewCell*)[nibsArray objectAtIndex:0];
}
//下边这个只可以目前 自己尝试 只可以 用在 6 之上
// RightTableViewCell *cell = (RightTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIndentifier];
//
// static NSString *CellIndentifier = @"RightTableViewCell";
// RightTableViewCell *cell = (RightTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIndentifier];
//
// if (cell == nil) {
// cell = [[[RightTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIndentifier] autorelease];
// }
[cell setBackgroundImage:nil];
NSString *tag = @"";
if (indexPath.section == 0) {
tag = [tagList count] == 0 ? @"" : [tagList objectAtIndex:indexPath.row];
}
NSString *imageFileName = @"tag.png";
[cell setIcon:[UIImage imageNamed:imageFileName]];
NSLog(@"----------- %@",tag);
[cell setName:tag];
UIView *backgroundView = [[UIView alloc] initWithFrame:cell.frame];
backgroundView.backgroundColor = TAG_SELECTED_BACKGROUND;
cell.selectedBackgroundView = backgroundView;
[backgroundView release];
return cell;
}
需要设置:
在 Interface Builder 里点击打开ViewController.xib。在你做任何其他事情之前,请先在nib里把Auto Layout禁用掉。你可以在File inspector里找到这个选项:
取消选择“Use Autolayout”复选框. 那么现在你的nib使用的是旧版本的 struts-and-springs 模式。
提示: 任何你通过Xcode4.5或者更高版本创建的新nib或者storyboard文件会默认使用Auto Layout。因为Auto Layout这个特性只有在IOS 6中有,所以如果你想要使用 Xcode4.5来做一些兼容IOS5的应用,你必须要在新的nib或者storyboard文件中通过取消选择“Use Autolayout”复选框来禁用Auto Layout。
- TableViewCell指定 xib文件 调试
- 表格01--用户自定义tableViewCell(带有xib文件的)
- xib动态加载tableViewCell
- tableViewCell与xib
- 使用 xib 创建 tableViewCell
- iOS 加载xib tableViewCell
- 加载xib 描述的 tableViewCell
- xib 创建tableviewCell的重用
- iOS 在tableViewcell的xib文件中添加新的控件 为null
- 自定义xib TableViewCell 标准写法 代码段
- UITableView with xib 以及自定义TableViewCell
- tableviewcell xib 使用 autolayout 从 -8 开始
- 【iOS】使用Xib自定义tableViewCell 获取数据
- iOS中使用xib定制动态tableViewCell
- 【swift】自定义xib 的tableviewcell的使用
- Xib使用之TableViewCell.xib中创建多个Cell
- Xib使用之TableViewCell.xib中创建多个Cell
- IOS关于XIB文件和调试时候显示不一样问题
- OpenCV(五): Opencv视频播放控制
- 十四条关于移动端产品设计的原则
- C ,C++ ,VC,VC++,MFC,API区别
- javaSE 4.1
- linux中nohup命令的用法
- TableViewCell指定 xib文件 调试
- 哈希表
- AOP面向方面编程
- Android-2.2 display系统介绍-SW架构
- 嵌入式linux移植ppp拨号上网脚本
- asp.net与word文档在线
- sql ,oracle语法
- Shell 备份文件
- Android 4.0开发之GridLayOut布局实践