繁体   English   中英

如何使用uialertiew导航?

[英]How do I navigate with uialertiew?

我决定删除该按钮,现在要导航。 这个想法很简单; 我想在单击“下一个站点”时将其转移到应用程序中的另一个站点。 但是我不知道该怎么做。

码:

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; 
    }
}
}

自iOS 8起,UIAlertView不再使用,应替换为UIAlertController。 对于UIAlertController,您可以提供操作。

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

在ActionHandler中,您可以切换到新页面。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM