我正試圖創建一個屏幕,像iOS中的Android屏幕 如何更改UiTableViewCell中的ImageView?
我的問題,在iOS中是圓圈。在iOS中,我將ImageView用於具有兩個png文件的圓圈:red_circle和green_circle。我需要使用紅色圓圈表示正值,綠色圓圈表示負值,但我不知道如何在代碼中檢查此情況。誰能幫我?我用MvvmCross使用Xamarin.iOS。
這是我的UIViewController:
public partial class MyProjectsView : MvxViewController<MyProjectsViewModel>
{
public MyProjectsView() : base("MyProjectsView", null)
{
}
public override void DidReceiveMemoryWarning()
{
base.DidReceiveMemoryWarning();
// Release any cached data, images, etc that aren't in use.
}
public async override void ViewDidLoad()
{
base.ViewDidLoad();
if (RespondsToSelector(new Selector("edgesForExtendedLayout")))
{
EdgesForExtendedLayout = UIRectEdge.None;
}
var source = new MvxSimpleTableViewSource(TblProjects, MyProjectsItem.Key, MyProjectsItem.Key);
TblProjects.Source = source;
this.CreateBinding(source).To<MyProjectsViewModel>(viewModel => viewModel.Projetos).Apply();
this.CreateBinding(LblSyncrhonizingData).For("Visibility").To<MyProjectsViewModel>(vm => vm.IsProgressBarVisible).WithConversion("Visibility").Apply();
this.CreateBinding(Activity).For("Visibility").To<MyProjectsViewModel>(vm => vm.IsProgressBarVisible).WithConversion("Visibility").Apply();
this.CreateBinding(LblDataSynchronized).For("Visibility").To<MyProjectsViewModel>(vm => vm.IsDataSynchronized).WithConversion("Visibility").Apply();
var bounds = UIScreen.MainScreen.Bounds;
var carregamento = new CarregamentoIOS(bounds);
View.Add(carregamento);
ViewModel.Carregamento = carregamento;
await ViewModel.PreencheLista();
}
}
這是我的UITableViewCell:
public partial class MyProjectsItem : MvxTableViewCell
{
public static readonly NSString Key = new NSString("MyProjectsItem");
public static readonly UINib Nib = UINib.FromName("MyProjectsItem", NSBundle.MainBundle);
protected MyProjectsItem(IntPtr handle) : base(handle)
{
this.DelayBind(() =>
{
this.CreateBinding(LblProjectName).To<Project>(project => project.Name).Apply();
this.CreateBinding(LblPercentage).To<Project>(project => project.PercentCompleted).WithConversion("IntToPercentCompleted").Apply();
this.CreateBinding(LblCostMoney).To<Project>(project => project.Cost.Variation).WithConversion("DoubleThousandToStringAbbreviation").Apply();
this.CreateBinding(LblCostDays).To<Project>(project => project.Schedule.Variation).WithConversion("IntToDaysAbbreviation").Apply();
});
}
public static MyProjectsItem Create()
{
return (MyProjectsItem)Nib.Instantiate(null, null)[0];
}
}
你的圈子的ImageView被定義在哪裏?也許你可以創建一個轉換器,它根據你的ViewModel的正值/負值來控制你的ImageView控件並綁定一個UIImage。 – Plac3Hold3r
我在XIB文件中定義了ImageView。我有兩個ImageViews的圈子和我的iOS項目中包含兩個PNG文件的文件夾:red_circle和green_circle。 –
你的MvxTableViewCell中有你的'ImageView'的上下文嗎? – Plac3Hold3r