2014-05-22 59 views

回答

3

對於名稱和圖像創建customview。

yourTable.tableHeaderView = yourCustomView_Name_image; 

對於消息,電話,聯繫與4 UIButtons

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 
{ 
    if(section == 0)//do this if you have multiple section. 
     return youroutletforcustomview_message_call_contact; 
    return nil; 
} 

創建customview也許這會幫助你。 :)

+1

工作!非常感謝!你讓我今天一整天都感覺很好 – Juanjo

0

讓這應該堅持到頂部表視圖節頭的東西。

1

使用硬編碼值要人爲的例子的一種可能的解決方案:

在視圖控制器創建兩個屬性:

@property (nonatomic, strong) UIView *stickyHeader; 
@property (nonatomic, assign) CGFloat stickyHeaderYPos; 

viewDidLoad

self.stickyHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 100.0, 320.0, 100.0)]; 
self.stickyHeader.backgroundColor = [UIColor blueColor]; 
[self.scrollView addSubview:self.stickyHeader]; 
self.stickyHeaderYPos = self.stickyHeader.frame.origin.y; 

// Allow us to scroll to test 
self.scrollView.contentSize = CGSizeMake(320.0, 2000.0); 

設置視圖控制器爲UIScrollViewdelegate,並執行scrollViewDidScroll

- (void)scrollViewDidScroll:(UIScrollView *)scrollView { 
    if (scrollView.contentOffset.y > self.stickyHeaderYPos) { 
     CGRect frame = self.stickyHeader.frame; 
     frame.origin.y = scrollView.contentOffset.y; 
     self.stickyHeader.frame = frame; 
    } 
}