我观察到非常奇怪的行为。我已将位于自定义单元格 View 内的 UIProgressView 绑定(bind)到我的 View 模型的 float 属性。这里要说明的是我在核心层的 View 模型:
public class DownloadCellViewModel: MvxViewModel
{
float _Progress;
public float Progress {
get{
return _Progress;
}
set{
_Progress = value;
this.RaisePropertyChanged (() => this.Progress);
}
}
}
这是我在 UI 前端层的单元格 View 绑定(bind)代码:
public DownloadCell (IntPtr handle) : base (handle)
{
this.DelayBind(() => {
var set = this.CreateBindingSet<DownloadCell, DownloadCellViewModel> ();
set.Bind(ProgressDownload).For(p=>p.Progress).To(item=> item.Progress);
set.Apply();
});
}
请注意,ProgressDownload 是一个 UIProgressView,我将其放在 xib 文件中。 现在的问题是,当我运行这段代码时,它在模拟器中按预期工作,但在设备上出现以下错误:
MvxBind:Warning:104,99 Failed to create target binding for binding Progress for Progress
有什么想法吗?
最佳答案
我相信链接器优化导致了问题 将以下内容添加到 LinkerPleaseInclude.cs 文件
public class LinkerIncludePlease
{
public void Include(MvxTableViewCell vc)
{
vc.BackgroundColor = UIColor.Blue;
}
}
关于ios - MVVMCross 绑定(bind)属性在 iOS 模拟器中工作正常,但在设备上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22249814/