2017-10-10 7 views
0

テーブルローでビューコントローラを開く方法segueの概念を使用せずにxamarin iosをクリックする方法?????テーブル行でビューコントローラを開く方法segueのコンセプトを使用せずにxamarin iosをクリックする方法

+0

これは非常に良い情報ですが、どこに問題がありますか?あなたが試したことなど、など? –

+0

こんにちは、私の質問は どのようにsegueの概念を使用せずにxamarin iosでテーブルの行をクリックしてビューコントローラを開くには????? –

答えて

0

下記のようにメソッド「RowSelectedを」上書きあなたは、ビューコントローラを提示するpresent(viewController, animated: true) {}、このメソッドを使用することができ、あなたはナビゲーションコントローラを持っている場合は、あなたのUITableViewSourceでnavigationController?.pushViewController(viewController, animated: true)

0

を使用することができます。

public override void RowSelected (UITableView tableView, NSIndexPath indexPath) 
{ 
    //Instantialte the Storyboard Object 
    UIStoryboard storyboard = UIStoryboard.FromName ("YourStoryboardName", null); 

    //Instantiate the ViewController you want to navigate to. 
    //Make sure you have set the Storyboard ID for this ViewController in your storyboard file. 
    //Put this Storyboard ID in place of the TargetViewControllerName in below line. 
    UIViewController vcInstance = (UIViewController)storyboard.InstantiateViewController ("TargetViewControllerName"); 


    //Get the Instance of the TopViewController (CurrentViewController) or the NavigationViewController to push the TargetViewController onto the stack. 
    //NavigationController is an Instance of the NavigationViewController 
    NavigationController.PushViewController(vcInstance, true); 
} 

または

イベントメカニズムの使用このイベントは、TableViewが追加されているMyTableSourceオブジェクトのViewControllerに登録します。

public class MyTableSource : UITableViewSource 
{ 
    public event EventHandler<RowSelectedEventArgs> OnRowSelected; 

    public override void RowSelected (UITableView tableView, NSIndexPath indexPath) 
    { 
     if (OnRowSelected != null) { 
      OnRowSelected (this, new RowSelectedEventArgs (tableView, indexPath)); 
    } 
} 


public class MyViewController : UIViewController 
{ 
    MyTableSourceObject.OnRowSelected += (s, ev) => { 
     //Your Navigation Logic Goes Here. 
    } 
} 
+0

View Controller内にない別のCSファイルにテーブルデータをバインドします。 –

+0

Foundation.MonoTouchException:Objective-C例外がスローされました。名前:NSInvalidArgumentException理由:バンドルNSBundle(ロード) ネイティブスタックトレース: \t 0 CoreFoundationの0x00000001134e4b0b __exceptionPreprocess + 171 \t 1 libobjc.A.dylib 0x00000001140a7141 –

+0

正しいストーリーボードの名前を与えていることを確認してください。 Ex。ストーリーボードのファイル名がMain.storyboardの場合、ストーリーボード名は「Main」にしてください。 – MilanG

関連する問題