2011-07-13 119 views
1

我正在開發一個應用程序,在該應用程序中我使用tableview在單元格中顯示圖像。我已經給出了一個單元格的大小作爲ipad屏幕的大小,並保持當我滾動tableview,它滾動到下一個cell.now我想放大每個單元格,因爲我有一個要求。爲了實現它,我採用了滾動視圖並將其放置在單元格的內容視圖上,並將圖像放置在滾動視圖上。如何在桌面視圖中縮放單元格

問題: 我面臨的問題是縮放沒有在cell上執行,手勢委託方法甚至沒有被調用。我對此感到驚訝,並開始在網上搜索「我們是否可以放大表格視圖中的單元格」,但找不到許多結果。

可以有人建議我,如果有一種方法來放大一個tableview中的小區?我們不能將scrollview放置在tableview單元格中嗎?

任何方法被理解。

TNQ

回答

1

我終於在等待幾天後回答我自己的問題。正如我在問題中所說的那樣,我想放大表格視圖的單元格中的內容,而我認爲這是不可能的。

我試圖將一個滾動視圖中的tableview的細胞內,並試圖放大,但手勢識別無法識別手勢,因爲它是表視圖滾動和滾動型我之間混淆。花費時間Google搜索和我自己的表格視圖和滾動經驗後,我做出了一個結論,我不能放大表格視圖單元格的內容。

i加至的tableview的超級視圖(滾動視圖是我上海華)分配的捏合姿態解決了我的情況下。只要捏確認我將表視圖單元格的內容視圖的內容複製到一個視圖,並將其添加到超級視圖,即滾動視圖,從而縮放視圖。稍後在執行縮放並縮放到一個之後,我從超級視圖中移除視圖。

這樣我解決了我的情況。

希望這將幫助其他有一個場景像我

TNQ

3

我也面臨這個問題。我通過以下途徑來解決這個問題: 我已經加入捏合手勢識別器的tableView的細胞和應用下面的代碼:

- (void)scalePiece:(UIPinchGestureRecognizer *)gestureRecognizer { 

    if ([gestureRecognizer state] == UIGestureRecognizerStateBegan || [gestureRecognizer state] == UIGestureRecognizerStateChanged) { 
     [gestureRecognizer view].transform = CGAffineTransformScale([[gestureRecognizer view] transform], [gestureRecognizer scale], [gestureRecognizer scale]); 
     [gestureRecognizer setScale:1]; 
    } 
    else if ([gestureRecognizer state] == UIGestureRecognizerStateEnded) 
    { 
    if([gestureRecognizer view].transform.b<0 && [gestureRecognizer view].transform.c<1) 
    { 
     [gestureRecognizer view].transform=CGAffineTransformMake(0,-1.0,1.0,0,0,0); 
    } 
    [gestureRecognizer view].transform = CGAffineTransformScale([[gestureRecognizer view] transform], [gestureRecognizer scale], [gestureRecognizer scale]); 
    [gestureRecognizer setScale:1]; 

    } 
} 
0

採用可變

NSInteger的SelectedIndex的

現在把這東西在

- (UITableViewCell *)tableView:(UITableView *)tableView 
    cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    //whatever your code write here 

    if (selectedindex == indexPath.row) { 
     [self animateZoomforCell:cell]; 
    }else 
    { 
     [self animateZoomforCellremove:cell]; 
    } 
    return cell; 
} 

- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    //whatever your code write here 

    selectedindex =indexPath.row; 
    [self.tableView reloadData]; 
} 

您可以使用此方法輸入/輸出單元

-(void)animateZoomforCell:(UITableViewCell*)zoomCell { 
     [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseOut 
      animations:^{ 

     zoomCell.transform = CGAffineTransformMakeScale(1.6,1.6); 
     } 
     completion:^(BOOL finished){ 
     }]; 
     } 

    -(void)animateZoomforCellremove:(UITableViewCell*)zoomCell { 
     [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ 

     zoomCell.transform = CGAffineTransformMakeScale(1.0,1.0); 
     } 
     completion:^(BOOL finished){ 
     }]; 
     } 
放大
相關問題