2012-04-14 20 views
2

我想要顯示UITableView,但是我想使用它與頁面控制。例如,如果用戶更改頁面,我顯示其他數據(在同一張桌子上)。使用UITableView的頁面

我知道我可以在點擊頁面控制後更改數據並重新加載表格。但是,我想要改變數據,當我滾動水平,我希望它看起來像我滑到其他表。我不知道如何啓動它?

我想折騰一樣,(而是用普通表):enter image description here

如何我可以開始了嗎?也許有任何開源的例子呢?

回答

1

創建具有分頁的UIScrollView的,請看這裏: http://www.iosdevnotes.com/2011/03/uiscrollview-paging/

然後,只需在每個子視圖創建的UITableView(頁)

+0

我做到了。但是,當我添加UIScrollView我的表視圖然後應用程序崩潰,我得到的信息,我沒有方法NumbersOfSections,但我有我的表控制器。 – kolek 2012-04-14 11:44:54

+0

它工作時,我有UITableView委託方法在我有UIpageControl相同的控制器。如果我在外部UIViewController與表中有它,那麼它不起作用。 – kolek 2012-04-15 20:16:02

0

不能完全確定是否能解決你的問題,但任何時候,我都希望有一個UITableView水平滾動而不是垂直滾動,我已將其翻轉到一側。

//Rotate the table 90 degrees counterclockwise 
CGAffineTransform rotateTable = CGAffineTransformMakeRotation(-M_PI_2); 
self.myTableView.transform = rotateTable; 
//Code to reset the position of your table as the rotation throws it off 

然後在的tableView:的cellForRowAtIndexPath:旋轉單元

//Rotate the cell 90 degrees clockwise 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    ... 

    CGAffineTransform rotateCell = CGAffineTransformMakeRotation(M_PI_2); 
    cell.transform = rotateCell;  

    return cell; 
} 

在每個單元中,你乾脆把代表一個 「屏幕」 或 「網頁」 的管制。作爲UIScrollView的UITableView支持分頁,所以你可以利用它。

2

我同意Oscar,使用UIScrollView有優點,您可以稍後使用一個很好的幻燈片動畫。看看PanelTableView控件。