简体   繁体   English

如何使用uialertiew导航?

[英]How do I navigate with uialertiew?

I've decided to delete the button, and now want to navigate. 我决定删除该按钮,现在要导航。 The idea is simple; 这个想法很简单; I want to, when I click ''Next Site'' be transfered to another site in the application. 我想在单击“下一个站点”时将其转移到应用程序中的另一个站点。 However I don't know how to do this. 但是我不知道该怎么做。

Code: 码:

using System;
using System.Collections.Generic;
using System.Text;
using Foundation;
using UIKit;

namespace TableView
{
public class TableSource : UITableViewSource
{
    string[] tableItems;
    string cellIdentifier = "TableCell"; 



    public TableSource (string[] items)
    {
        tableItems = items; 
    }

    public override nint RowsInSection(UITableView tableview, nint section)
    {
        return tableItems.Length; 
    }
    public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
    {
        new UIAlertView("Alert", "You selected: " + tableItems[indexPath.Row], null, "Next Site", null).Show();
        tableView.DeselectRow(indexPath, true); 
    }
    public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
    {
        UITableViewCell cell = tableView.DequeueReusableCell(cellIdentifier);
        if (cell == null)
            cell = new UITableViewCell(UITableViewCellStyle.Subtitle, cellIdentifier);
        cell.TextLabel.Text = tableItems[indexPath.Row];

        if(indexPath.Row > -1)
            cell.DetailTextLabel.Text = tableItems[indexPath.Row - 0];



            return cell; 
    }
}
}

UIAlertView is depricated since iOS 8 and should be replaced with UIAlertController. 自iOS 8起,UIAlertView不再使用,应替换为UIAlertController。 For an UIAlertController you can provide actions. 对于UIAlertController,您可以提供操作。

var alert = UIAlertController.Create("Title", "Message", UIAlertControllerStyle.Alert);
alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, ActionHandler));

Inside your ActionHandler you can switch to your new page. 在ActionHandler中,您可以切换到新页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在这两个列表之间导航? - How do I navigate between these two lists? 如何在iOS的MonoTouch / Xamarin中导航名称空间? - How do I navigate namespaces in MonoTouch / Xamarin for iOS? 如何导航到基于UILocalNotification的详细信息视图? - How do I navigate to a detail view based on UILocalNotification? 如何在使用 SwiftUI 的同时导航到视图 Controller? - How do I navigate to a View Controller while also using SwiftUI? 如何有条件地选择下一个视图控制器进行导航? - How do I conditionally select the next view controller to navigate to? SwiftUI 如何在子视图上导航到新的导航页面 - SwiftUI How do I navigate on Child View to a new navigation page 如何使用 SwiftUI 中的按钮在视图之间导航? - How do I navigate between views using a button in SwiftUI? 如何使用按钮在UIPageViewController中向前和向后导航? - How do I navigate forward and backward within UIPageViewController using buttons? 如何通过点击图像按钮导航到我的 SecondView? - How do I navigate to my SecondView by tapping image button? 当环境对象更新导致同一视图重新加载时,如何导航到另一个 SwiftUI 视图 - How do I navigate to another SwiftUI View when an Environment Object update is causing the same view to reload
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM