【发布时间】:2015-07-16 13:28:07
【问题描述】:
很抱歉再次发布此问题,但我查看了很多答案,但都没有帮助解决我的问题。
这是我的代码:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *cellIdentifier = @"radioCell";
RadioTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[RadioTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellIdentifier];
}
[self configureCommentCell:cell atIndexPath:indexPath];
return cell;
}
当我向下滚动时,我的单元格被混淆并且一些数据重复,所以我尝试了这个:
static NSString *CellIdentifier = @"memberCell";
RadioCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[RadioTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
}
还有这个:
RadioTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:nil];
if (cell == nil) {
cell = [[RadioTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];
}
但它并没有解决我的问题,我得到白色的空单元格?请问这个问题怎么解决?
更新
- (void)configureCommentCell:(RadioTableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath {
NSDictionary *object;
if ([_dataArray[indexPath.section] isKindOfClass:[NSArray class]])
object = [_dataArray[indexPath.section] objectAtIndex:indexPath.row];
else
object = [[_dataArray[indexPath.section] valueForKey:@"radioList"] objectAtIndex:indexPath.row];
if (object[@"jsonUrl"]) {
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:object[@"jsonUrl"] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
//NSDictionary *tempObject = (NSDictionary *) responseObject;
if (![[responseObject objectForKey:@"type"] isEqualToString:@"error"]) {
NSDictionary *tempObject = [responseObject[@"data"] objectAtIndex:0];
cell.playingNow.text = tempObject[@"song"];
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
}
cell.name.text = [NSString stringWithFormat:@" %@", object[@"title"]];
if (object[@"logoUrl"])
[cell.logo setImageWithURL:[NSURL URLWithString:object[@"logoUrl"]]];
}
【问题讨论】:
-
能否请您添加您的方法 cellforrow..?
-
@AbhishekSharma 是的,检查我的更新
-
@Leo 检查我的更新
-
@AbhishekSharma 这里有什么更新吗?
标签: ios objective-c uitableview cocoa-touch uikit