-1

我正在使用 UITableViewController。

在我触摸表格中的特定行后,我不想显示警报视图,而是希望被重定向到另一个页面。

我有这个代码,但它不起作用

public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
{
    new UIAlertView("Row Selected", tableItems[indexPath.Row], null, "OK", null).Show();
    tableView.DeselectRow (indexPath, true); // normal iOS behaviour is to remove the blue highlight

    //call the next screen
    if(this.accountRegistration== null) {
        this.accountRegistration = new AccountRegistration();
    } 

    this.NavigationController.PushViewController(this.accountRegistration,    true); 

}
4

2 回答 2

1

我正在更改我的答案,因为我没有意识到您使用的是 UITableViewController。

在您的 AppDelegate.cs 文件中,您需要将 rootNavigationController 设置为新的 UINavigationController:

    [Register ("AppDelegate")]
    public partial class AppDelegate : UIApplicationDelegate
    {
        // class-level declarations
        UIWindow window;
        UINavigationController rootNavigationController;

        public override bool FinishedLaunching (UIApplication app, NSDictionary options)
        {
            this.window = new UIWindow (UIScreen.MainScreen.Bounds); 
            //---- instantiate a new navigation controller 
            this.rootNavigationController = new UINavigationController(); 
            this.rootNavigationController.PushViewController(new MyUITableViewController(), false);

            //---- set the root view controller on the window. the nav 
            // controller will handle the rest
            this.window.RootViewController = this.rootNavigationController;
            this.window.MakeKeyAndVisible (); 
            return true;
        }

        .... 

从那时起,您的 UITableViewController 应该始终具有对 this.NavigationController 的引用。

于 2013-07-26T14:43:27.627 回答
0

此代码运行良好

[Register("AppDelegate")] public partial class AppDelegate : UIApplicationDelegate { // 类级声明 UIWindow window; UINavigationController 根导航控制器;

    public override bool FinishedLaunching (UIApplication app, NSDictionary options)
    {
        this.window = new UIWindow (UIScreen.MainScreen.Bounds); 
        //---- instantiate a new navigation controller 
        this.rootNavigationController = new UINavigationController(); 
        this.rootNavigationController.PushViewController(new MyUITableViewController(), false);

        //---- set the root view controller on the window. the nav 
        // controller will handle the rest
        this.window.RootViewController = this.rootNavigationController;
        this.window.MakeKeyAndVisible (); 
        return true;
    }
于 2013-07-29T01:08:41.583 回答