2016-06-29 84 views
0

我已經決定刪除​​按鈕,現在想導航。這個想法很簡單,我想,當我點擊''下一個網站''被轉移到應用程序中的另一個網站。但我不知道該怎麼做。如何使用uialertiew進行導航?

代碼:因爲iOS 8的

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

如果問題太模糊,或寫得不好,你可以刪除它或編輯它。 – AnonymUser

+0

'UIAlertView'在iOS8 +中已棄用,您應該使用'UIAlertController'來處理。 – holex

+0

看到這個:https://iosdevcenters.blogspot.com/2016/03/uialertcontroller-in-swift.html,在與點擊確定按鈕導航你想要的。 –

回答

0

UIAlertView中被depricated並應與UIAlertController代替。對於UIAlertController,您可以提供操作。

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

在ActionHandler內部,您可以切換到新頁面。

相關問題