具有静态内容的xamarin/mvvmcross UITableView
我已经搜索了xamarin教程和xamarin中关于UITableView的各种帖子,但是我找不到关于UITableView和静态单元格的任何内容 我试图实现的是一个简单的细节屏幕,比如twitterific应用程序,但是没有Nib或故事板(使用mvvmcross,故事板不可用,Nib文件阻止使用静态UITableView,至少我找不到任何方法) 此外,在尝试不同的解决方案后,我得到了如下结果: UITableViewController具有静态内容的xamarin/mvvmcross UITableView,uitableview,mvvmcross,xamarin-studio,Uitableview,Mvvmcross,Xamarin Studio,我已经搜索了xamarin教程和xamarin中关于UITableView的各种帖子,但是我找不到关于UITableView和静态单元格的任何内容 我试图实现的是一个简单的细节屏幕,比如twitterific应用程序,但是没有Nib或故事板(使用mvvmcross,故事板不可用,Nib文件阻止使用静态UITableView,至少我找不到任何方法) 此外,在尝试不同的解决方案后,我得到了如下结果: UITableViewController public override int NumberOf
public override int NumberOfSections(UITableView tableView)
{
return 1;
}
public override int RowsInSection(UITableView tableview, int section)
{
return 1;
}
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
UITableViewCell cell = tableView.DequeueReusableCell("test");
if (cell == null)
{
cell = new SejourInfoViewPatientCell();
//cell = new UITableViewCell(UITableViewCellStyle.Subtitle, "test");
}
//cell.TextLabel.Text = "test";
return cell;
}
但是现在mvvmcross绑定不起作用。如果我使用完全相同的绑定并在非静态UITableViewController上使用它,一切都会正常工作
如果有人能给我指个方向,我会很高兴的
我不确定什么是
静态
表格视图或单元格,但我刚刚发布了一个使用“自定义单元格”的完整示例,以回答
关键部分是:
- 确保自定义单元格包含
构造函数IntPtr
- 对自定义单元格类型使用注册表ClassForcellReuse
- 覆盖表源中的
,并使用GetOrCreateCellFor
创建单元格DequeueReusableCell
对于可变高度单元格,您还需要覆盖表源中的
GetHeightForRow
我不确定什么是static
表视图或单元格,但我刚刚发布了一个完整的示例,使用“自定义单元格”来回答
关键部分是:
- 确保自定义单元格包含
构造函数IntPtr
- 对自定义单元格类型使用注册表ClassForcellReuse
- 覆盖表源中的
,并使用GetOrCreateCellFor
创建单元格DequeueReusableCell
对于可变高度单元格,还需要覆盖表源中的
GetHeightForRow
,我一直在努力解决同样的问题。通过让视图从MvxViewController
继承,然后在ViewDidLoad
中,我可以绕过绑定问题:
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
UITableView table = new UITableView();
Action<UITableViewCell> initializers = new Action<UITableViewCell>[] {
(cell) => {
this.CreateBinding(cell.TextLabel)
.For(c => c.Text)
.To(x => x.FirstName)
.Apply();
},
(cell) => {
this.CreateBinding(cell.TextLabel)
.For(c => c.Text)
.To(x => x.LastName)
.Apply();
}
};
StubDataSource source = new StubDataSource(table, initializers);
table.Source = source;
}
有两点需要注意
我一直在努力解决同样的问题。通过让视图从
MvxViewController
继承,然后在ViewDidLoad
中,我可以绕过绑定问题:
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
UITableView table = new UITableView();
Action<UITableViewCell> initializers = new Action<UITableViewCell>[] {
(cell) => {
this.CreateBinding(cell.TextLabel)
.For(c => c.Text)
.To(x => x.FirstName)
.Apply();
},
(cell) => {
this.CreateBinding(cell.TextLabel)
.For(c => c.Text)
.To(x => x.LastName)
.Apply();
}
};
StubDataSource source = new StubDataSource(table, initializers);
table.Source = source;
}
有两点需要注意
对于静态,我指的是具有固定节和单元格的UITableViewCell(在Xcode>4.2中,通过将单元格类型更改为“static”,您可以非常轻松地做到这一点)。对于静态,我指的是具有固定节和单元格的UITableViewCell(在Xcode>4.2中,通过将单元格类型更改为“static”,您可以非常轻松地做到这一点)。抱歉,我的回答太晚了,我正在进行另一个项目。但是它工作得很好,非常感谢:)没问题,顺便说一句,我发现monotouch对话框组件可以很好地解决我试图使用静态表解决的许多问题。退房了,很抱歉回答晚了,我在做另一个项目。但是它工作得很好,非常感谢:)没问题,顺便说一句,我发现monotouch对话框组件可以很好地解决我试图使用静态表解决的许多问题。退房