2014-01-21 1 views
0

iOS 자습서를 따르고 있으며 코드가 정확하지만 처음 튜토리얼 코드에 표시되지 않은 오류가 발생합니다. 다음은 관련된 방법은 다음과 같습니다다른 메서드에서 BOOL 메서드를 호출하려고 할 때 경고가 발생했습니다.

-(BOOL)tableview:(UITableView *)tableView canCollapseSection:(NSInteger)section { 

    if (section >0) return YES; 

    return NO; 

} 

그리고 여기에 올바른 있어야 코드의 조각,하지만 오류가 발생합니다 :

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    if (tableView == self.searchDisplayController.searchResultsTableView) 
    { 
     return [self.searchResults count]; 
    } 
    else { 



     if ([self tableView:tableView canCollapseSection:section]) 

     { 
      if ([expandedSections containsIndex:section]) 
      { 
       .../... 

오류가 라인

if ([self tableView:tableView canCollapseSection:section]) 

에 표시됩니다 다음은 오류 메시지입니다.

No visible @interface for 'ToDoItemsTableViewController' declares the selector 'tableView:canCollapseSection:' 

답변

2

당신은 tableView를 호출하고 있지만 tableview 여야합니다. 작은 'V'

+0

즉, @ santhu 감사합니다. – mvasco

2

.h 파일에

-(BOOL)tableview:(UITableView *)tableView canCollapseSection:(NSInteger)section 

를 선언

코드에서 보이는 오류가 있습니까? ....

또한 정확하게 입력했는지 확인하십시오. 맞춤법 오류로 인해 문제가 발생할 수도 있습니다.

+1

내가 제안한 것을 생각하고 있었지만 튜토리얼에서 직접 나와 같은 .m 파일에 선언되었습니다. – mvasco

+1

@mvasco : 예, 오타를 눈치 채지 못했습니다. 그게 문제 야. 만약 당신이 .h 파일에 선언 할 필요가없는 private 메소드를 선언했다면 .h 파일에서도 선언 할 수있다. –

2
- (BOOL)tableView:(UITableView *)tableView canCollapseSection:(NSInteger)section 

있는 tableView : V는 후 확인하시기 바랍니다 자본해야한다 - (BOOL) :

+0

감사합니다. 산투와 같은 대답. 내 편이라. – mvasco

1

당신은 단지 yourViewController.h에 당신의 방법

-(BOOL)tableview:(UITableView *)tableView canCollapseSection:(NSInteger)section 

를 선언 할 필요가있는 tableview 부분 파일.

관련 문제