2012-12-06 40 views
0

我插入的UITableView like this url image分段。如果你看到網址的形象,現在我在uitable工作確定一切數據,IOS - UISegmented中的UITableView

和...

當我向下滾動表我想第1部分:圖像(URL)將滾動滾動到部分2:分段將停止,如果您仍然滾動可用第3部分:數據將滾動(保持在頂部分段)。

你有任何想法。謝謝

回答

2

我只是測試它,它工作!

  1. 設置你的UITableView疼痛

  2. UITableView中有兩個部分,每個部分僅有一行。

  3. 編輯您的部分標題時,確保只有第二部分有標題 - 第二個標題將是您的part2。

  4. 第一節第一行是你的part1。

  5. 第二節第一行是你的part3。

就是這樣:)

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

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

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 
     static NSString *CellIdentifier = @"Cell"; 
     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
     if (cell == nil) { 
      cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
     } 

     cell.textLabel.text = @"test"; 

     return cell; 
} 

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ 
    @try { 
     UIView *containerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 30)]; 
     switch (section) { 
      case 0: 
      { 
       //nothing 
      } 
       break; 
      case 1: 
      { 
       UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 30)]; 
       lbl.text = @"second"; 
       lbl.textColor = [UIColor blackColor]; 
       [containerView addSubview:lbl]; 
      } 
       break; 
     } 
     return containerView; 
    } 
    @catch (NSException *exception) { 
    } 
} 

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

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ 
    return 1000.0; 
} 
+0

謝謝@布賴恩快速回答,我會嘗試! – heaven

+0

完成!非常感謝!! @布賴恩 – heaven