创建UITableViewCell程序奔溃
来源:互联网 发布:网站主持人源码 编辑:程序博客网 时间:2024/09/21 06:33
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return 3;}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString * cellID=@"cellID"; UITableViewCell * cell=[tableView dequeueReusableCellWithIdentifier:cellID forIndexPath:indexPath]; if (!cell) { cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID]; } UIImageView * imgView=[cell viewWithTag:232]; if (imgView==nil) { imgView=[[UIImageView alloc]initWithFrame:CGRectMake(screenSize.width-110, 10, 100, 60)]; [cell addSubview:imgView]; } imgView.image=[UIImage imageNamed:@"sxd"]; cell.textLabel.text=@"哈哈"; return cell;}- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 80;}
每次程序一运行就出错,看不出哪里不合适,报错
Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3512.60.7/UITableView.m:6573
觉得没什么不对啊这个方法,搜索之后发现把
UITableViewCell * cell=[tableView dequeueReusableCellWithIdentifier:cellID forIndexPath:indexPath];
改为<p style="margin-top: 0px; margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures;">UITableViewCell</span><span style="font-variant-ligatures: no-common-ligatures;"> * cell=[tableView </span><span style="font-variant-ligatures: no-common-ligatures;">dequeueReusableCellWithIdentifier</span><span style="font-variant-ligatures: no-common-ligatures;">:cellID];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 175, 202);">就对啦,明天再追加两个方法的区别,虽然很低级的错误</p>
0 0
- 创建UITableViewCell程序奔溃
- 创建UITableViewCell
- Xib文件创建UITableViewCell
- UITableViewCell的创建
- Xib文件创建UITableViewCell
- 使用代码创建UITableViewCell
- 正确地创建UITableViewCell
- UITableViewCell对象的创建方式
- 使用xib文件创建UITableViewCell
- UITableViewCell组合创建(React Native)
- 代码动态创建UITableViewCell小结
- 创建一个可重用的UITableViewCell代码
- 创建UITableViewCell(不使用XIB情况)
- iOS中创建UITableViewCell的正确姿态
- UITableViewCell
- UITableViewCell
- UITableViewCell
- UITableViewCell
- ImageView中src与background的区别
- HDU 5706 GirlCat DFS解决
- hive 内置操作符
- 传输层TCP协议
- 【垂直搜索引擎搭建13】HtmlParser中Visitor实践
- 创建UITableViewCell程序奔溃
- eclipse如何安装genymotion插件,终于安装成功了,终极方案
- 集合框架的讲解--面试常问问题
- linux把标准输出赋值给变量遇到的问题
- 我的webpack配置文件
- 树的同构
- 排序算法——快速排序
- Android.mk和Application.mk文件语法规范说明及举例
- 传输层UDP协议