2013-01-11 1 views
3

Le problème consiste en la liaison à un UIBarButtonItem, le code fonctionne sur Simulator, mais sur le périphérique la propriété Enable doesn ' t le travail et les travaux cliqués ...Problèmes avec la liaison mvvmcross sur IOS (fonctionne sur le simulateur, mais certaines propriétés ne fonctionnent pas sur le périphérique)

Le même problème existe dans le textViewItem, mais cette fois ni le texte ni l'autorisation ne fonctionne.

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

Merci à l'avance

[EDIT]

La sortie de l'application: 11.01.2013 09: 16: 56,369 LinkFENACAMSIGEPMobileUIIPad [6496: C07] Navigation: Diagnostic: 2,24 Naviguer vers MainMenuViewModel avec args

11/01/2013 09: 16: 56,369 LinkFENACAMSIGEPMobileUIIPad [6496: C07] TouchNavigation : diagnostic: 2,24 Naviguer demandé

11/01/2013 09: 16: 56,421 LinkFENACAMSIGEPMobileUIIPad [6496: C07] MvxBind: Attention: 2,29 Incapable de se lier à la source est nulle

11/01/2013 09: 16: 56.423 LienFENACAMSIGEPMobileUIIPad [6496: c07] MvxBind: avertissement: 2.29 Impossible de lier à la source est null

[EDIT 20130111: 11: 12] - Linker Comportement: assemblies SDK Link ne

similiar à: MvvmCross Monotouch - Fail to bind Properties on a real iPad, but it works on the Simulator (je ne peux pas faire ce travail ...)

Répondre

7

je peux » t voir le bouton à barres dans l'exemple de code inclus - donc je vais répondre en fonction du texte, cliqué, activé, etc

Si cela fonctionne dans le simulateur, mais pas sur l'appareil, les chances sont que c'est de faire avec le Linker - exactement comme dans MvvmCross Monotouch - Fail to bind Properties on a real iPad, but it works on the Simulator

Pour tester cette théorie, essayez de l'éditeur de liens pour inclure tous les symboles


À supposer que c'est la cause du problème ... alors pour contourner ce que vous devez inclure un fichier LinkerPleaseInclude.cs qui trick le lieur en incluant ces propriétés.

Par exemple, il pourrait bien ressembler à:

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

Note: que ce code est jamais réellement exécuté, mais il est analysé par le linker au moment de la construction.

+0

** Merci !! **, j'ai forcé le Linker et changer l'option de lien et ça marche! – ptorrezao

+0

Merci Stuart, qui a sauvé ma journée - même deux ans plus tard. –

Questions connexes