2016-05-02 83 views
0

你好我想加載一個UIView,當你點擊一行uitableview。 我這樣做,因爲它是這個鏈接: ViewController Segue Xamarin 但是在打印,Man.storyboard,並且還有模擬器給出以下錯誤。 下面是具有uitableview和UITableViewSource代碼的視圖代碼。 我很感激任何人都可以提供幫助。用uitableview加載UIView

enter image description here

enter image description here

partial class ListaWodsFemininosViewController : BaseController2 
{ 
    public ListaWodsFemininosViewController (IntPtr handle) : base (handle) 
    { 
    } 

    public override void ViewDidLoad() 
    { 
     base.ViewDidLoad(); 

     DetalheWodViewController detalhe = (DetalheWodViewController)Storyboard.InstantiateViewController("detalhe"); 

     List<WodReferencia> Wods = new List<WodReferencia>(); 

     WodReferencia ref0 = new WodReferencia { 
      Nome  = "Amanda", 
      Feminino = "Three rounds, 9-7- and 5 reps, of:\n" + 
       "Muscle-up 135 pound Squat snatch.", 
      Masculino = "Three rounds, 9-7- and 5 reps, of: " + 
       "Muscle-up 135 pound Squat snatch." 

     }; 
     Wods.Add (ref0); 

     WodReferencia ref1 = new WodReferencia { 
      Nome  = "Angie", 
      Feminino = "100 Pull-ups 100 Push-ups 100 Sit-ups 100 Squats.", 
      Masculino = "100 Pull-ups 100 Push-ups 100 Sit-ups 100 Squats." 
     }; 
     Wods.Add (ref1); 

     WodReferencia ref2 = new WodReferencia { 
      Nome  = "Annie", 
      Feminino = "Double-unders Sit-ups 50-40-30-20 and 10 rep rounds.", 
      Masculino = "Double-unders Sit-ups 50-40-30-20 and 10 rep rounds." 
     }; 
     Wods.Add (ref2); 

     WodReferencia ref3 = new WodReferencia { 
      Nome  = "Barbara", 
      Feminino = "20 Pull-ups 30 Push-ups 40 Sit-ups 50 Squats Rest precisely 3 minutes between each round. 5 rounds, time each round.", 
      Masculino = "20 Pull-ups 30 Push-ups 40 Sit-ups 50 Squats Rest precisely 3 minutes between each round. 5 rounds, time each round." 
     }; 
     Wods.Add (ref3); 

     WodReferencia ref4 = new WodReferencia { 
      Nome  = "Chelsea", 
      Feminino = "5 Pull-ups 10 Push-ups 15 Squats Each minute on the minute for 30 minutes.", 
      Masculino = "5 Pull-ups 10 Push-ups 15 Squats Each minute on the minute for 30 minutes." 
     }; 
     Wods.Add (ref4); 

     WodReferencia ref5 = new WodReferencia { 
      Nome  = "Christine", 
      Feminino = "3 rounds for time of: 500 m Row 12 BW Deadlift 21 Box Jumps.", 
      Masculino = "3 rounds for time of: 500 m Row 12 BW Deadlift 21 Box Jumps." 
     }; 
     Wods.Add (ref5); 

     WodReferencia ref6 = new WodReferencia { 
      Nome  = "Cindy", 
      Feminino = "5 Pull-ups 10 Push-ups 15 Squats As many rounds as possible in 20 minutes.", 
      Masculino = "5 Pull-ups 10 Push-ups 15 Squats As many rounds as possible in 20 minutes." 
     }; 
     Wods.Add (ref6); 

     ... 

     gridWods.Source = new FonteTabelaWodsFeminino (Wods,detalhe); 
    } 

    public override void PrepareForSegue (UIStoryboardSegue segue, NSObject sender) 
    { 
     if (segue.Identifier == "detalhe") { 
      var detalhe = segue.DestinationViewController as DetalheWodViewController; 
     } 
    } 
} 

public class FonteTabelaWodsFeminino : UITableViewSource 
{ 

    private List<WodReferencia> wodsFemininos; 
    DetalheWodViewController detLocal; 
    private string cellIdentifier = "TableCell"; 

    public FonteTabelaWodsFeminino (List<WodReferencia> wodsF, DetalheWodViewController det) 
    { 
     wodsFemininos = wodsF; 
     this.detLocal = det; 
    } 

    public override nint RowsInSection (UITableView tableview, nint section) 
    { 
     if (wodsFemininos != null) { 
      return wodsFemininos.Count; 
     } else { 
      return 0; 
     } 
    } 

    public override UITableViewCell GetCell (UITableView tableView, Foundation.NSIndexPath indexPath) 
    { 
     UITableViewCell cell   = tableView.DequeueReusableCell (cellIdentifier); 
     if (cell == null) 
      cell = new UITableViewCell (UITableViewCellStyle.Subtitle, cellIdentifier); 

     cell.TextLabel.Lines   = 0; 
     cell.TextLabel.SizeToFit(); 
     cell.TextLabel.LineBreakMode = UILineBreakMode.WordWrap; 
     cell.DetailTextLabel.Text  = wodsFemininos [indexPath.Row].Masculino; 
     cell.TextLabel.Text    = wodsFemininos [indexPath.Row].Nome; 
     return cell; 
    } 

    public override void RowSelected (UITableView tableView, NSIndexPath indexPath) 
    { 
     detLocal.PerformSegue("detalhe", detLocal); 
    } 
} 
+0

我看不到你得到的錯誤。你能用它更新這篇文章嗎?錯誤發生在哪一行?如果您需要幫助查找該行,請使用異常斷點。 –

+0

請不要發佈錯誤的屏幕上限。搜索引擎不能索引屏幕大小。花時間在文章中複製錯誤並進行格式化,使其可讀。 – Jason

+0

我按照上面的圖片進行了調整。 在下面的標識符中。 但仍然沒有奏效。 該行給出的問題是: detLocal.PerformSegue(「detail」,detLocal);方法: public override void RowSelected(UITableView tableView,NSIndexPath indexPath) –

回答

1

認爲你需要給你的賽格瑞的ID如下:

enter image description here

只注意到使用Xamarin的iOS設計師你所以這裏是截圖爲此也;)

enter image description here