与mvvmcross绑定的IOS(模拟器上工作,但某些属性不会对设备工作)的问题(Problems

2019-07-18 03:15发布

问题在于对绑定到的UIBarButtonItem,代码工作的模拟器,但属性启用不工作的设备和被点击的作品上...

在textViewItem存在同样的问题,但这次无论是文字或启用的作品。

    public partial class ProcessDetailViewController : MvxBindingTouchViewController<ProcessDetailViewModel>
{
    public ProcessDetailViewController (MvxShowViewModelRequest request)
        : base (request,"ProcessDetailViewController", null)
    {
    }

    public override void DidReceiveMemoryWarning ()
    {
        // Releases the view if it doesn't have a superview.
        base.DidReceiveMemoryWarning ();

        // Release any cached data, images, etc that aren't in use.
    }

    public override void ViewDidLoad ()
    {
        base.ViewDidLoad ();
        this.AddBindings(
            new Dictionary<object, string>()
            {
            { this.lblSeguradoraNome , "{'Text':{'Path':'AssuranceCompanyID'}}" },
            { this.lblSeguradoraGestor , "{'Text':{'Path':'AssuranceManager'}}" },
            { this.lblApoliceData , "{'Text':{'Path':'InsurancePolicyStartDate'}}" },
            { this.lblApoliceNum , "{'Text':{'Path':'InsurancePolicyNumber'}}" },
            { this.lblApoliceRamo , "{'Text':{'Path':'InsurancePolicyBranch'}}" },
            { this.lblDataPedido , "{'Text':{'Path':'RequestDate'}}" },
            { this.lblGestor , "{'Text':{'Path':'InternalManager'}}" },
            { this.lblLocalRiscoCodPostal , "{'Text':{'Path':'InsurancedLocationAddressCityZipCode'}}" },
            { this.lblLocalRiscoConcelho , "{'Text':{'Path':'InsurancedLocationAddressCity'}}" },
            { this.lblLocalRiscoMorada , "{'Text':{'Path':'InsurancedLocationAddress'}}" },
            { this.lblPerito , "{'Text':{'Path':'Surveyer'}}" },
            { this.lblSeguradoCodPostal , "{'Text':{'Path':'InsuredPersonAddressCityZipCode'}}" },
            { this.lblSeguradoConcelho , "{'Text':{'Path':'InsuredPersonAddressCity'}}" },
            { this.lblSeguradoContacto , "{'Text':{'Path':'InsuredPersonPhone'}}" },
            { this.lblSeguradoMorada , "{'Text':{'Path':'InsuredPersonAddress'}}" },
            { this.lblSeguradoNome , "{'Text':{'Path':'InsuredPersonName'}}" },
            { this.btnDownload , "{'Clicked':{'Path':'DownloadProcessButton'},'Enabled':{'Path':'HideIfDownloaded'}}" },
            { this.btnTerminarVisita , "{'Clicked':{'Path':'EndVisitButton'},'Enabled':{'Path':'ShowIfOnVisit'}}" },
            { this.btnObterLocalizacao , "{'Clicked':{'Path':'AdquireLocationButton'},'Enabled':{'Path':'ShowIfOnVisit'}}" },
            { this.btnIniciarVisita , "{'Clicked':{'Path':'BeginVisitButton'},'Enabled':{'Path':'HideIfOnVisit'}}" },
            { this.btnTirarFoto , "{'Clicked':{'Path':'TakePhotoButton'},'Enabled':{'Path':'ShowIfOnVisit'}}" },
            { this.btnVoltar , "{'Clicked':{'Path':'ReturnButton'}}" },
            { this.btnUpload , "{'Clicked':{'Path':'UploadProcessButton'},'Enabled':{'Path':'CanUpload'}}" },
            }
        );
    //  var a= NavigationItem.LeftBarButtonItems[0].Enabled

        // Perform any additional setup after loading the view, typically from a nib.
    }

    public override void ViewDidUnload ()
    {
        base.ViewDidUnload ();

        // Clear any references to subviews of the main view in order to
        // allow the Garbage Collector to collect them sooner.
        //
        // e.g. myOutlet.Dispose (); myOutlet = null;

        ReleaseDesignerOutlets ();
    }

    public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
    {
        // Return true for supported orientations
        return true;
    }
 }

 public class ProcessDetailViewModel : ProcessNavigationBaseViewModel
{(...)}

public class ProcessNavigationBaseViewModel : BaseViewModel
{
    (...)

    #region Properties
    private Process _currentProcess;

    private static User _user;

    private bool _isGPSLocationStarted;

    private double _latitude;

    private double _longitude;

    private string _photoFilename = "";

    public Process CurrentProcess
    {
        get
        {
            return _currentProcess;
        }
        set
        {
            _currentProcess = value;
            FirePropertyChanged(() => CurrentProcess);
        }
    }

    public User User
    {
        get { return _user; }
        set
        {
            _user = value;
            FirePropertyChanged(() => User);
        }
    }

    private bool _isDownloaded
    {
        get
        {
            return CurrentProcess.IsLockedInServer && !(CurrentProcess.ProcessState == ProcessState.WaitingReportProduction.ToString());
        }
        set
        {
            CurrentProcess.IsLockedInServer = value;
            FirePropertyChanged(() => ShowIfDownloaded);
            FirePropertyChanged(() => HideIfDownloaded);
        }
    }

    public bool ShowIfDownloaded
    {
        get { return _isDownloaded; }
    }

    public bool HideIfDownloaded
    {
        get { return !_isDownloaded; }
    }

    public bool CanUpload
    {
        get { return ( CurrentProcess.ProcessState == ProcessState.WaitingUpload.ToString()); }
    }

    public bool CanDownload
    {
        get { return (CurrentProcess.ProcessState != ProcessState.WaitingReportProduction.ToString() && 
                                    CurrentProcess.ProcessState == ProcessState.WaitingSurveyorAcceptionDecision.ToString()) ;  }
    }

    public bool ShowIfOnVisit
    {
        get { return (CurrentProcess.ProcessState == ProcessState.OnVisist.ToString()); }
    }

    public bool HideIfOnVisit
    {
        get { return (!(CurrentProcess.ProcessState == ProcessState.OnVisist.ToString())) && ShowIfDownloaded; }
    }

    public string ProcessDescription
    {
        get
        {
            return string.Format("{0} - {1}", CurrentProcess.ProcessNumber, CurrentProcess.RequestedService.RequestedServiceType);
        }
    }
(...)
 }

提前致谢

[编辑]

应用输出:2013年1月11日09:16:56.369 LinkFENACAMSIGEPMobileUIIPad [6496:C07]导航:诊断:2.24导航与参数传递给MainMenuViewModel

2013年1月11日09:16:56.369 LinkFENACAMSIGEPMobileUIIPad [6496:C07] TouchNavigation:诊断:2.24导航请求

2013年1月11日09:16:56.421 LinkFENACAMSIGEPMobileUIIPad [6496:C07] MvxBind:警告:2.29无法绑定到源是空

2013年1月11日09:16:56.423 LinkFENACAMSIGEPMobileUIIPad [6496:C07] MvxBind:警告:2.29无法绑定到源是空

仅链接SDK组件: - [EDIT 20130111::11 12] 链接器行为

类同: MvvmCross MonoTouch的-不能结合于一个真实的iPad的性能,但它工作在模拟器 (我不能做这项工作?)

Answer 1:

我看不出在示例代码的barbutton包括 - 所以我会回答基于文本,点击,启用,等等。

如果这是工作在模拟器,而不是设备上,机会是,这是做的链接-酷似MvvmCross MonoTouch的-不能结合于一个真实的iPad的性能,但它工作在模拟器

为了验证这一理论,尝试打开链接到包括所有的符号


假设这是问题的原因......然后要解决它,你需要包括LinkerPleaseInclude.cs文件,该文件会欺骗链接到包括这些属性。

例如,它可能只是看起来像:

public class LinkerIncludePlease
{
    private void IncludeClicked(UIButton button)
    {
        button.Clicked += (s, e) => { };
    }

    private void IncludeEnabled(UIButton button)
    {
        button.Enabled = !button.Enabled;
    }

    private void IncludeText(UILabel label)
    {
        label.Text = label.Text + "test";
    }
}

注意:此代码是从来没有实际执行,而是由链接器在生成时分析。



文章来源: Problems with mvvmcross Binding on IOS (Works on Simulator, but some properties doesn't work on the Device)