【发布时间】:2015-03-11 23:36:18
【问题描述】:
我创建了一个自定义表格视图单元格
@interface FixtureTableViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *teamsVSTextLabel;
@property (weak, nonatomic) IBOutlet UILabel *teamsScoreDetailLabel;
@end
我向服务器发出异步数据请求,当它返回时,我重新加载表数据。这是我的
//reload table data when request is over
-(void)finished
{
self.pastFixturesArray = aPastFixture.pastFixturesArray;
[self.tableView reloadData];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
FixtureTableViewCell *cell = (FixtureTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"pastFixtureCell" forIndexPath:indexPath];
// Configure the cell...
PastFixture *thisFixture = [pastFixturesArray objectAtIndex:indexPath.row];
//string to store the match result and score result
NSMutableString *matchString = [[NSMutableString alloc] init];
NSMutableString *matchScoreString = [[NSMutableString alloc] init];
//configure match string
[matchString appendFormat:@"%@ vs %@",thisFixture.homeTeam.teamName, thisFixture.awayTeam.teamName];
//configure the score string
[matchScoreString appendFormat:@"%ld - %ld", thisFixture.homeScore, thisFixture.awayScore];
//configure cell labels
cell.teamsVSTextLabel.text = matchString;
cell.teamsScoreDetailLabel.text = matchScoreString;
cell.teamsScoreDetailLabel.textColor = [UIColor blueColor];
return cell;
}
如果我在第一次加载视图时填充表格并且我不重新加载表格数据,则自定义单元格有效,如果我不使用自定义单元格,它也有效,因此问题特定于重新加载我的表格自定义单元格。有人可以帮忙吗?
编辑我收到 EXC_BAD_ACCESS code=2 错误消息,所以这可能与内存有关
编辑 2 我的线程 1:
编辑 3:我认为这是问题所在。使用自定义单元格,我得到空对象:/
这是我的自定义单元的实现文件:
#import "FixtureTableViewCell.h"
@implementation FixtureTableViewCell
@synthesize teamsVSTextLabel, teamsScoreDetailLabel;
- (void)awakeFromNib {
// Initialization code
}
-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
teamsVSTextLabel.text = @".";
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
【问题讨论】:
-
请发布完整的符号化堆栈跟踪以及您收到的确切错误消息。
-
你能告诉我怎么做吗?
-
看起来你有一个无限循环。你能扩展线程 1 吗?
-
你看到“CA::Layer::ensure_transaction...”左边的数字了吗?这就是它被调用的次数。您以某种方式创建了一个循环返回自身的 UIView 结构。
标签: ios objective-c uitableview