我有一个Xamarin.IOS应用程序,并使用MvvmCross和ResxPlugin进行翻译。这在调试中没有问题。但是自从我从5.3.x更新到5.6.3后,应用程序在发布模式下崩溃,链接器设置为"仅限链接框架SDK"当我尝试执行以下行时:
bindingSet.Bind(textViewWelcomeMessage)
.For(txt => txt.Text)
.To(vm => vm.TextSource)
.WithConversion(new MvxLanguageConverter(), "WelcomeMessage");
这没有问题:
bindingSet.Bind(textFieldAgreementText)
.For(lbl => lbl.AttributedText)
.To(vm => vm.GeneralAgreementText)
.WithConversion("StringToHtml");
所以我认为问题出在MvxLanguageConverter和textFields的组合中。
在我的" LinkerPleaseInlude"文件我添加了这个:
public void Include(UITextView textView)
{
textView.Text = textView.Text + "";
textView.AttributedText = new NSAttributedString();
textView.Changed += (sender, args) => { textView.Text = ""; };
}
输出中的错误消息是:
2018-01-24 09:37:39.415 ConnectContacts.Ios[27680:1063685] System.ArgumentNullException: missing source event info in MvxWeakEventSubscription
Parameter name: sourceEventInfo
at MvvmCross.Platform.WeakSubscription.MvxWeakEventSubscription`2[TSource,TEventArgs]..ctor (UIKit.NSTextStorage source, System.Reflection.EventInfo sourceEventInfo, System.EventHandler`1[TEventArgs] targetEventHandler) [0x00017] in <6adc0d5857264558a9d45778a78ae02a>:0
at MvvmCross.Platform.WeakSubscription.MvxWeakEventSubscription`2[TSource,TEventArgs]..ctor (UIKit.NSTextStorage source, System.String sourceEventName, System.EventHandler`1[TEventArgs] targetEventHandler) [0x00012] in <6adc0d5857264558a9d45778a78ae02a>:0
at MvvmCross.Platform.WeakSubscription.MvxWeakSubscriptionExtensionMethods.WeakSubscribe[TSource,TEventArgs] (TSource source, System.String eventName, System.EventHandler`1[TEventArgs] eventHandler) [0x00000] in <6adc0d5857264558a9d45778a78ae02a>:0
at MvvmCross.Binding.iOS.Target.MvxUITextViewTextTargetBinding.SubscribeToEvents () [0x00053] in <614c9ef828c14ba687a40ec2656f480f>:0
at MvvmCross.Binding.Bindings.MvxFullBinding.CreateTargetBinding (System.Object target) [0x00057] in <866b1e46764b48aab0d408952a6f006f>:0
at MvvmCross.Binding.Bindings.MvxFullBinding..ctor (MvvmCross.Binding.MvxBindingRequest bindingRequest) [0x0002f] in <866b1e46764b48aab0d408952a6f006f>:0
at MvvmCross.Binding.Binders.MvxFromTextBinder.BindSingle (MvvmCross.Binding.MvxBindingRequest bindingRequest) [0x00000] in <866b1e46764b48aab0d408952a6f006f>:0
at MvvmCross.Binding.Binders.MvxFromTextBinder+<>c__DisplayClass2_0.<Bind>b__0 (MvvmCross.Binding.Bindings.MvxBindingDescription description) [0x00018] in <866b1e46764b48aab0d408952a6f006f>:0
at System.Linq.Enumerable+SelectArrayIterator`2[TSource,TResult].MoveNext () [0x0003a] in <8bc31b0df50a4d32b3f1d5af764165ad>:0
at MvvmCross.Binding.BindingContext.MvxBindingContextOwnerExtensions.AddBindings (MvvmCross.Binding.BindingContext.IMvxBindingContextOwner view, System.Object target, System.Collections.Generic.IEnumerable`1[T] bindings, System.Object clearKey) [0x0001d] in <866b1e46764b48aab0d408952a6f006f>:0
at MvvmCross.Binding.BindingContext.MvxBindingContextOwnerExtensions.AddBindings (MvvmCross.Binding.BindingContext.IMvxBindingContextOwner view, System.Object target, System.Collections.Generic.IEnumerable`1[T] bindingDescriptions, System.Object clearKey) [0x00018] in <866b1e46764b48aab0d408952a6f006f>:0
at MvvmCross.Binding.BindingContext.MvxBindingContextOwnerExtensions.AddBinding (MvvmCross.Binding.BindingContext.IMvxBindingContextOwner view, System.Object target, MvvmCross.Binding.Bindings.MvxBindingDescription bindingDescription, System.Object clearKey) [0x0000b] in <866b1e46764b48aab0d408952a6f006f>:0
at MvvmCross.Binding.BindingContext.MvxBaseFluentBindingDescription`1[TTarget].Apply () [0x0001f] in <866b1e46764b48aab0d408952a6f006f>:0
at MvvmCross.Binding.BindingContext.MvxFluentBindingDescriptionSet`2[TOwningTarget,TSource].Apply () [0x00016] in <866b1e46764b48aab0d408952a6f006f>:0
at ConnectContacts.Ios.Views.Wizard.WelcomeView.ViewDidLoad () [0x001ae] in <b2a318752d5d4fbeb6d32a83c8b6f752>:0
--- End of stack trace from previous location where exception was thrown ---
我是否必须使用新版本制作不同的内容?
答案 0 :(得分:2)
您需要在LinkerPleaseInlude
UITextView
添加以下内容
textView.TextStorage.DidProcessEditing += (sender, e) => textView.Text = "";
请参阅此GitHub issue