首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >带有转换的MvvmCross Xamarin IOS TextView绑定不再有效

带有转换的MvvmCross Xamarin IOS TextView绑定不再有效
EN

Stack Overflow用户
提问于 2018-01-24 16:44:00
回答 1查看 377关注 0票数 0

我有一个Xamarin.IOS应用程序,并使用MvvmCross和ResxPlugin进行翻译。这在调试中没有出现任何问题。但是,因为我从5.3.x更新到5.6.3,所以当我尝试执行下面这行代码时,应用程序在发布模式下崩溃,链接器设置为"Link Framework SDKs“:

代码语言:javascript
运行
复制
bindingSet.Bind(textViewWelcomeMessage)
                      .For(txt => txt.Text)
                      .To(vm => vm.TextSource)
                      .WithConversion(new MvxLanguageConverter(), "WelcomeMessage");

这是没有问题的:

代码语言:javascript
运行
复制
bindingSet.Bind(textFieldAgreementText)
                  .For(lbl => lbl.AttributedText)
                  .To(vm => vm.GeneralAgreementText)
                  .WithConversion("StringToHtml");

因此,我假设问题出在结合了textFields的MvxLanguageConverter中。

在我的"LinkerPleaseInlude“文件中,我添加了以下内容:

代码语言:javascript
运行
复制
    public void Include(UITextView textView)
    {
        textView.Text = textView.Text + "";
        textView.AttributedText = new NSAttributedString();
        textView.Changed += (sender, args) => { textView.Text = ""; };
    }

输出中的错误消息为:

代码语言:javascript
运行
复制
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 ---

我必须用新版本做一些不同的东西吗?

EN

Stack Overflow用户

回答已采纳

发布于 2018-01-24 17:03:30

您需要将以下内容添加到UITextViewLinkerPleaseInlude

代码语言:javascript
运行
复制
textView.TextStorage.DidProcessEditing += (sender, e) => textView.Text = "";

查看此GitHub issue

票数 2
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48418164

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档