2012-06-21 25 views
0

我有這個類來創建日期源。如何使用此課程創建UIViewController爲我的類源創建一個UIViewController,如何?

public partial class JogosSource : UITableViewSource { 

    List<TableItem> tableItems; 
    string cellIdentifier = "TableCell"; 

    public JogosSource (List<TableItem> items) 
    { 
    } 

    public override int RowsInSection (UITableView tableview, int section) 
    { 
    } 

    public override void RowSelected (UITableView tableView, NSIndexPath indexPath) 
    { 
    } 

    public override UITableViewCell GetCell (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath) 
    { 
    } 
} 
+1

你到底想要什麼?僅包含tableview的視圖控制器? – CarlosJ

回答

1

我不太確定我理解你的問題。

UITableViewSource是一個將UITableViewDelegateUITableViewDataSource組合成一個包含兩者方法的方便類。

所以,如果你想使用這個類,JogoSource在你的情況,寫在MT文檔需要

分配此對象的實例到UITableView.Source財產。

要創建你可以按照三種不同的方式一個UITableView元素:

  • 子類的UITableViewController(這個類有一個表中查看自己的)

  • 子類UIViewController有自己的XIB ,在主視圖中拖動表格並將其與插座連接

  • 子類a UIViewController(wi日自己的廈門國際銀行,這是可選的),通過代碼

設置Source您表視圖的實例中ViewDidLoad方法可以完成創建表。例如,在這裏你確定網點設置正確。

this.YourTable = new JogoSource(yourItems); 

簡單建議

通常情況下,當你處理一個UITableViewSource類,你也可以注入其構造內的控制器,「控制」該來源。例如,在處理UINavigationController的情況下,這可能很有用。

所以,我會改變的JogoSource的點擊率

public JogosSource (UIViewController injectedController, List<TableItem> items) 
{ 
    // _controller is a private var of type UIViewController 
    _controller = injectedController; 
} 

如果您的控制器插入,例如,在UINavigationController,你需要表現出一些細節,當你選擇一排,由_controller手段您訪問父項(UINavigationController的一個實例)。

P.S.還有其他的可能性來創建一個表,但我列出了主要的。此外,請檢查代碼,因爲我手寫的。

希望有所幫助。

相關問題