【发布时间】:2018-08-10 16:07:47
【问题描述】:
我有一个自定义标签控件,其中仅将字体更改为粗体。 从 Appstore 获得以下崩溃日志,我无法重现。 崩溃日志指向使用我的自定义控件导航到 .xaml。
public class CustomLabelBold : Label
{
public CustomLabelBold()
{
FontFamily = "Avenir Next";
}
}
以下是崩溃日志:
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0
Thread 0 name:
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x00000001814492ec __pthread_kill + 8
1 libsystem_pthread.dylib 0x00000001815ea288 pthread_kill$VARIANT$mp + 376 (pthread.c:1484)
2 libsystem_c.dylib 0x00000001813b7db0 __abort + 152 (abort.c:128)
3 libsystem_c.dylib 0x00000001813b7d18 abort + 152 (abort.c:99)
4 MyProject 0x00000001031046e0 print_callback(char const*, int) + 39061216 (runtime.m:1216)
5 MyProject 0x00000001030ff1a8 monoeg_g_log + 39039400 (goutput.c:125)
6 MyProject 0x00000001030ba098 major_alloc_object + 38756504 (sgen-marksweep.c:697)
7 MyProject 0x00000001030dbec4 copy_object_no_checks + 38895300 (sgen-copy-object.h:71)
8 MyProject 0x00000001030db470 simple_nursery_serial_scan_object + 38892656 (sgen-minor-copy-object.h:250)
9 MyProject 0x00000001030dbdf0 simple_nursery_serial_drain_gray_stack + 38895088 (sgen-gray.h:191)
10 MyProject 0x00000001030b390c finish_gray_stack + 38729996 (sgen-gc.c:1099)
11 MyProject 0x00000001030b29d0 collect_nursery + 38726096 (sgen-gc.c:1807)
12 MyProject 0x00000001030af388 sgen_perform_collection + 38712200 (sgen-gc.c:2534)
13 MyProject 0x00000001030a5f00 sgen_alloc_obj_nolock + 38674176 (sgen-alloc.c:257)
14 MyProject 0x00000001030a639c sgen_alloc_obj + 38675356 (sgen-alloc.c:423)
15 MyProject 0x000000010307f100 mono_gc_alloc_obj + 38514944 (sgen-mono.c:948)
16 MyProject 0x0000000100ce46a8 wrapper_managed_to_native_object___icall_wrapper_mono_gc_alloc_obj_intptr_intptr + 104
17 MyProject 0x0000000100cde564 wrapper_alloc_object_AllocSmall_intptr_intptr + 228
18 MyProject 0x0000000100fd71c4 Xamarin_Forms_Core_Xamarin_Forms_BindableObject__ctor + 4272580 (.D:\agent\_work\1\s\Xamarin.Forms.Core\BindableObject.cs:1)
19 MyProject 0x000000010103326c Xamarin_Forms_Core_Xamarin_Forms_VisualElement__ctor + 4649580 (.D:\agent\_work\1\s\Xamarin.Forms.Core\VisualElement.cs:122)
20 MyProject 0x0000000100fe3bc0 Xamarin_Forms_Core_Xamarin_Forms_View__ctor + 4324288 (.D:\agent\_work\1\s\Xamarin.Forms.Core\View.cs:24)
21 MyProject 0x000000010100fa9c Xamarin_Forms_Core_Xamarin_Forms_Label__ctor + 4504220 (.D:\agent\_work\1\s\Xamarin.Forms.Core\Label.cs:57)
22 MyProject 0x00000001018bd5e4 Core_MyProject_Core_CustomControls_CustomLabelBold__ctor + 20
【问题讨论】:
-
请显示
Constants.FontStyleAvenir是什么 -
编辑了问题。常量定义为 :public const string FontStyleAvenir = "Avenir Next";
-
你确定你的应用可以找到
Avenir Next吗?另外,如果你只想让你的标签加粗,正确的做法是FontAttributes = FontAttributes.Bold; -
@DennisSchröer 是的,检查过,我也在其他屏幕的整个应用程序中使用相同的字体。此外,我有一个用于 CustomLabelBold 的 android 渲染器,我在其中设置了不同的字体和填充
-
你能展示一下你的iOS渲染器的代码吗?