gpt4 book ai didi

c# - 使用 uitableview 加载 UIView

转载 作者:行者123 更新时间:2023-11-29 01:00:56 25 4
gpt4 key购买 nike

你好我想在你点击一行uitableview时加载一个UIView。我这样做是因为它是这个链接: ViewController Segue Xamarin但是在打印时给出了以下错误,Man.storyboard 和模拟器也有。下面是带有 uitableview 的 View 代码以及 UITableViewSource 的代码。如果有人可以提供帮助,我将不胜感激。

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

最佳答案

认为您需要为您的 segue 提供一个 Id,如下所示:

enter image description here

刚刚注意到您使用了 Xamarin iOS 设计器,因此这里也有屏幕截图;)

enter image description here

关于c# - 使用 uitableview 加载 UIView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36991576/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com