2014-04-25 2 views
1

ViewView 헤더로 높이 672의 뷰를로드 할 수 있습니까? 추가했습니다. 그러나 스크롤하고 테이블 뷰 셀 세부 정보를 볼 수 없습니다. 내가 나머지보기에서 코드TableHeader로보기를 추가해야합니까?

ACCRemainderView *header = [ACCRemainderView customHeaderView]; 

[self.tableView setTableHeaderView:header]; 

을 사용했다

+ (id)customHeaderView 
{ 
    ACCRemainderView *customView = [[[NSBundle mainBundle] loadNibNamed:@"ACCRemainderView" owner:nil options: 
            nil] lastObject]; 

    //make sure customView is not nil or the wrong class!   
    if ([customView isKindOfClass:[ACCRemainderView class]]) { 
     return customView; 
    } else { 
     return nil; 
    } 
} 
+0

실제 문제는 무엇입니까? – limon

+0

Nib 파일을 TableView 헤더로로드했지만 스크롤하고 tableview 세부 정보를 볼 수 없습니다. – user3564554

+0

테이블에 단 하나의 섹션 만있는 경우 섹션 헤더 –

답변

1

당신의 UITableViewController- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section을 구현하는 시도하고 [ACCRemainderView customHeaderView]을 반환합니다.

0

Set tableHeaderView가 가장 좋습니다. 나는 그것을 테스트하고 작동합니다.

ViewForHeaderInSection은이보기에서 머리글의 높이가 테이블의 높이보다 크기 때문에 수행 할 수 없습니다.

스크롤 할 수 없습니다, 당신의 tableView 다른보기에 의해 겹치는 생각합니다.

- (void)viewDidLoad 
{ 
[super viewDidLoad]; 

_tableView.dataSource = self; 
_tableView.delegate = self; 
} 

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 
{ 
NSString *title=[self tableView:tableView titleForHeaderInSection:section]; 
if (!title) 
    return nil; 


UIView *view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 500)]; 
view.backgroundColor = [UIColor greenColor]; 
return view; 
} 

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section 
{ 
return 500; 
} 


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
return 2; 
} 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
return 2; 
} 

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section 
{ 
return @"abcd"; 
} 

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
return 50; 
} 


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
static NSString *CellIdentifier = @"Cell"; 
UITableViewCell *cell = (UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
} 
cell.textLabel.text = @"a"; 
return cell; 
} 
관련 문제