2016-05-02 2 views
0

Привет, я хочу загрузить UIView, когда вы нажимаете на строку uitableview. Я сделал как-то ссылку: ViewController Segue Xamarin Но все ошибки при печати: Man.storyboard, а также есть симулятор. Ниже приведен код просмотра, который имеет uitableview, а также код UITableViewSource. Я ценю, если кто-то может помочь.Загрузка UIView с uitableview

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

Подумайте, вы должны дать свой SEGUE идентификатор, как так:

enter image description here

Просто заметил, вы используете дизайнер Xamarin IOS так вот скриншот для этого тоже;)

enter image description here

Смежные вопросы