2014-10-29 60 views
0

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

代码是:

- (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。任何人都可以帮我解决这个问题。

我试图借助属性的帮助,但不起作用。感谢您阅读我的文章。

+0

哪一行发生此错误?你使用了一个异常断点吗? – ZeMoon 2014-10-29 09:31:27

+0

问题是你的ViewController实例。这是被释放的对象。这种方法涉及的只是一个症状。你应该展示你如何创建和呈现ViewController – 2014-10-29 09:32:08

+0

嘿@ZeMoon我已经使用了断点,但并没有在viewForHeaderInSection方法中显示错误 – Tendulkar 2014-10-29 09:43:17

回答

-1

无论何时调用viewForHeaderInSection,都会释放tableview的委托。 确保你的viewcontroller是委托并检查它何时何地被取消分配。

+0

这是不正确 – ZeMoon 2014-10-29 09:51:46