section方法中viewForHeader中的崩溃问题

时间:2014-10-29 09:12:36

标签: ios xcode uitableview

在使用我的应用程序时拖动控制中心时出现此崩溃问题。崩溃消息为[ViewController tableView:viewForHeaderInSection:]: message sent to deallocated instance 0x17dbb9a0

代码是:

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    if(section == self.groupsArray.count)
    {            
        customView = [[UIView alloc] initWithFrame:CGRectMake(10.0, 0.0, 300.0, 24.0)];
        [customView setBackgroundColor:[UIColor clearColor]];

        return customView;
    }

    return nil;
}

我正在使用Xcode 6并启用ARC。任何人都可以帮我解决这个问题。

我试图接受“属性”的帮助,但不起作用。感谢您阅读我的帖子。

1 个答案:

答案 0 :(得分:-1)

每当调用viewForHeaderInSection时,都会释放 tableview的委托。  确保您的viewcontroller是委托,并检查它被取消分配的时间和地点。