【发布时间】:2009-12-10 08:56:03
【问题描述】:
我有一些表格,它由表格视图中的 5 个自定义单元格组成。代码如下:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;}
\- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 5;
}
\- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"in here");
static NSString *MyIdentifier = @"MyIdentifier";
FreeSignupCell *cell = (FreeSignupCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
NSLog(@"shazam");
cell = [[[FreeSignupCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
switch (indexPath.row) {
case 0:
NSLog(@"index 0");
[cell setLabelContent:@"First Name"];
//self.firstName = [cell getText];
break;
case 1:
NSLog(@"index 1");
[cell setLabelContent:@"Last Name"];
//self.lastName = [cell getText];
break;
case 2:
NSLog(@"index 2");
[cell setLabelContent:@"Company (optional)"];
//self.company = [cell getText];
break;
case 3:
NSLog(@"index 3");
[cell setLabelContent:@"Website (optional)"];
[cell setText: @"http://"];
//self.website = [cell getText];
break;
case 4:
NSLog(@"index 4");
[cell setLabelContent:@"E-mail"];
//self.email = [cell getText];
break;
default:
[cell setLabelContent:@"E-mail"];
}
return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 70.0;
}
问题是,当我编辑第一个字段时,快速滚动到最后一个字段时,应用程序崩溃并出现 objc_mssend 错误。
有什么想法吗?
【问题讨论】:
-
看起来您的问题一定是在 FreeSignupCell 类中的某个地方...在您发布的代码中看不到任何问题
-
不做任何编辑就上下滚动会不会报错?您可以将代码发布到 FreeSignupCell 吗?尝试打开 NSZombie 以查看正在释放的内容。
-
不,就在我尝试编辑的时候。有趣的是它发生在模拟器中,而不是在设备上。我很困惑
标签: iphone uitableview crash scroll