我如何使用uialertiew导航?

时间:2016-06-29 08:20:03

标签: ios xamarin

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

代码:

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

1 个答案:

答案 0 :(得分:0)

UIAlertView自iOS 8开始被取消,应该用UIAlertController取代。对于UIAlertController,您可以提供操作。

@ManagedBean(name="usersView", eager=true)
@ApplicationScoped

private ArrayList<String> selectedRoles;

public Arraylist<String> getSelectedRoles()
{
    return this.selectedRoles;
}

public void setSelectedRoles(ArrayList<String> roles)
{
    this.selectedRoles = roles;
}

public void editUserRole(ActionEvent actionEvent)
{
    // This method literally just loops through all users and matches the one we're looking at
    User user = findUser();

    if (user != null)
    {
        // gives user checked roles in database and local session
        addSelectedRoles(user);

        ArrayList<String> rolesToRemove = user.getRoleNames();
        rolesToRemove.removeAll(selectedRoles);

        // removes user unchecked roles in database and local session
        removeSelectedRoles(user, rolesToRemove);
    }

    else
    {
        // Handle exception...
    }
}

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