2013-10-23 1 views
4

나는 UITableViewControllerNSFetchedResultsController을 지원합니다. tableview가 비어있을 때마다 NIB에서로드 된 사용자 정의 backgroundview를 설정하려고합니다.사용자 정의 BackgroundView를 searchDisplayController를 사용하여 UITableView로 설정하려고하면 메시지가 할당 취소 된 인스턴스로 전송됩니다.

- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { 

    NSInteger numberOfSections = [super numberOfSectionsInTableView:tableView]; 

    if (tableView != self.searchDisplayController.searchResultsTableView) { 

     if (numberOfSections == 0 || 
      (numberOfSections == 1 && [super tableView:tableView numberOfRowsInSection:0] == 0)) 
      [tableView setBackgroundView:[self viewForEmptyTable]]; 
     else 
      [tableView setBackgroundView:nil]; 
    } 
    return numberOfSections; 
} 

- (TableViewEmptyBGView*) viewForEmptyTable { 

    if (_viewForEmptyTable == nil) { 
     NSArray* viewForEmptyTableNIB = [[NSBundle mainBundle] loadNibNamed:@"iPhone-ViewForEmptyTable" 
                     owner:nil 
                    options:nil]; 

     _viewForEmptyTable = [viewForEmptyTableNIB firstObject]; 
     [_viewForEmptyTable setHeader:self.listaVaziaHeaderText]; 
     [_viewForEmptyTable setBody:self.listaVaziaBodyText]; 
    } 

    return _viewForEmptyTable; 
} 

스크린 샷 : 나는 일이에 붙어하고 이전과 비슷한 문제를 가지고 쓸데없이 사람을 찾기 위해 노력했습니다 https://dl.dropboxusercontent.com/u/628444/Crash-Screenshots.png

. *** -[UIView isHidden]: message sent to deallocated instance 0xc6cf440

그것은 보인다 다음의 tableview가 비어로드 된 경우 괜찮 (1), 그러나 fetchedresultcontroller (2) 셀을 포함하는 경우 (3)과 후 (4)와 응용 프로그램의 충돌 (5) 것을 제거입니다

# Event Type ∆ RefCt RefCt Timestamp Responsible Library Responsible Caller 
    Malloc/Retain/Release (8)   00:09.546.357 UIKit -[UITableView setTableHeaderBackgroundColor:] 
0 Malloc +1 1 00:09.546.357 UIKit -[UITableView setTableHeaderBackgroundColor:] 
1 Retain +1 2 00:09.546.385 UIKit -[UIView(Internal) _addSubview:positioned:relativeTo:] 
2 Retain +1 3 00:09.546.409 UIKit -[UISearchDisplayController _configureSearchBarForTableView] 
3 Retain +1 4 00:09.546.474 UIKit -[UIView(Hierarchy) subviews] 
4 Release -1 3 00:09.552.790 UIKit -[UIView(Internal) _invalidateSubviewCache] 
11 Release -1 2 01:22.884.181 UIKit -[UIView(Hierarchy) removeFromSuperview] 
12 Release -1 1 01:22.884.182 UIKit -[UITableView setTableHeaderBackgroundColor:] 
13 Release -1 0 01:22.884.182 UIKit -[UISearchDisplayController _updateTableHeaderBackgroundViewInTableView:amountScrolledUnder:] 
    Retain/Release (6)   00:09.563.097 UIKit -[UIView(Hierarchy) subviews] 
5 Retain +1 4 00:09.563.097 UIKit -[UIView(Hierarchy) subviews] 
6 Retain +1 5 00:09.657.977 UIKit -[UIView(Hierarchy) subviews] 
7 Retain +1 6 00:09.808.482 QuartzCore -[CALayer layoutSublayers] 
8 Release -1 5 00:09.808.483 QuartzCore -[CALayer layoutSublayers] 
9 Release -1 4 00:09.821.299 QuartzCore CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) 
10 Release -1 3 01:22.877.290 UIKit -[UIView(Internal) _invalidateSubviewCache] 
14 Zombie  -1 01:22.884.204 UIKit -[UISearchDisplayController _updateTableHeaderBackgroundViewInTableView:amountScrolledUnder:] 
+1

지금 당장 똑같은 문제가 발생합니다. 내가 일하는 코드는 프로그래밍 방식으로 tableview를 만드는 데 사용되었고 IB로 옮길 때 같은 오류가 발생하기 시작했습니다. – dccarmo

+0

내 대답을 아래에서 살펴보고 문제가 해결되는지 확인하십시오. –

답변

2

그것은 emptyView 강한 참조 속성을 작성하는 할당이 해제 된 인스턴스에 보낸 메시지의 문제를 해결 밝혀하십시오 할당이 해제 된 객체에 메시지를 보낼하려고 UISearchDisplayController에 관련된 뭔가.

@interface ListObjectsCoreDataTVC() 
    @property (nonatomic, strong) TableViewEmptyBGView* viewForEmptyTable; 
@end