1

DialogViewController 包含一个 EntryElement 并设置了 RefreshRequested 处理程序(请参见下面的代码)。在模拟器中运行,调试模式,在 EntryElement 中键入一些快速的随机文本(包含空格)。崩溃将随之而来。

我做错了什么?

我猜这是 DialogViewController 中的一个错误,没有保留一些垃圾收集的图像。是否有跟踪垃圾收集器和删除对象的开关?

违规代码:

[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
    // class-level declarations
    UIWindow window;
    UINavigationController navController;
    DialogViewController dv ;


    public override bool FinishedLaunching (UIApplication app, NSDictionary options)
    {
        // create a new window instance based on the screen size
        window = new UIWindow (UIScreen.MainScreen.Bounds);

        navController = new UINavigationController();
        var root = new RootElement("Test") {
            new Section("Quick type some text") {
                new EntryElement("that contains spaces", string.Empty, string.Empty)
            }
        };

        dv = new DialogViewController(root, true);
        dv.RefreshRequested += HandleDvRefreshRequested; // comment this line fixes the bug
        window.MakeKeyAndVisible ();


        if (UIDevice.CurrentDevice.CheckSystemVersion (5, 0)) {
            window.RootViewController = navController;
        } else {
            window.AddSubview (navController.View);
        }

        return true;
    }

    void HandleDvRefreshRequested (object sender, EventArgs e)
    {
       dv.ReloadComplete();
    }
}
   启动 iOS 模拟器 5.0
   启动应用程序
   应用程序启动。PID = 4730
   加载的程序集:/Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll [外部]
   加载的程序集:/Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll [外部]
   加载的程序集:/Developer/MonoTouch/usr/lib/mono/2.1/System.dll [外部]
   话题开始:
   加载程序集:/Users/user/Documents/iphone-cinetoile/Cinetoile.UI2/bin/iPhoneSimulator/Debug/MyApp.exe
   加载的程序集:/Developer/MonoTouch/usr/lib/mono/2.1/MonoTouch.Dialog-1.dll [外部]
   加载的程序集:/Developer/MonoTouch/usr/lib/mono/2.1/Mono.Security.dll [外部]
   加载的程序集:/Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.dll [外部]

堆栈跟踪:

  在(包装器托管到本机)MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr)
  在 MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x00042] 在 /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29
  在 /Users/user/Documents/MyApp/Main.cs:17 中的 MyApp.Application.Main (string[]) [0x00000]
  在(包装器运行时调用).runtime_invoke_void_object(对象,intptr,intptr,intptr)

本机堆栈跟踪:

0   MyApp                               0x000908ec mono_handle_native_sigsegv + 284
1   MyApp                               0x00005c88 mono_sigsegv_signal_handler + 248
2   libSystem.B.dylib                   0x9141905b _sigtramp + 43
3   ???                                 0xffffffff 0x0 + 4294967295
4   ???                                 0x92c013ef 0x0 + 2462061551
5   ???                                 0x92c011ee 0x0 + 2462061038
6   ???                                 0x987a313c 0x0 + 2558144828
7   CoreGraphics                        0x91b49e20 CGDataProviderRetain + 22
8   ???                                 0x9880c456 0x0 + 2558575702
9   ImageIO                             0x9754a0d2 CGImageReadCreateWithProvider + 185
10  ImageIO                             0x97549fee CGImageSourceCreateWithDataProvider + 186
11  CoreGraphics                        0x013c0d2f CGImageCreateWithPNGDataProvider + 87
12  WebCore                             0x073ca2a5 WKGraphicsCreateImageFromBundleWithName + 373
13  WebCore                             0x06c1c5bd _ZN7WebCore15GraphicsContext23drawLineForTextCheckingERKNS_10FloatPointEfNS0_21TextCheckingLineStyleE + 369
14  WebCore                             0x06cf6e84 _ZN7WebCore13InlineTextBox28paintSpellingOrGrammarMarkerEPNS_15GraphicsContextERKNS_10FloatPointERKNS_14DocumentMarkerEPNS_11RenderStyleERKNS_4FontEb + 1684
15  WebCore                             0x06cf6fb9 _ZN7WebCore13InlineTextBox20paintDocumentMarkersEPNS_15GraphicsContextERKNS_10FloatPointEPNS_11RenderStyleERKNS_4FontEb + 297
16  WebCore                             0x06cf33fc _ZN7WebCore13InlineTextBox5paintERNS_9PaintInfoEiiii + 6490
17  WebCore                             0x06cec3cd _ZN7WebCore13InlineFlowBox5paintERNS_9PaintInfoEiiii + 1065
18  WebCore                             0x0724d24c _ZN7WebCore13RootInlineBox5paintERNS_9PaintInfoEiiii + 64
19  WebCore                             0x071a8e2a _ZNK7WebCore17RenderLineBoxList5paintEPNS_20RenderBoxModelObjectERNS_9PaintInfoEii + 638
20  WebCore                             0x07142089 _ZN7WebCore11RenderBlock11paintObjectERNS_9PaintInfoEii + 369
21  WebCore                             0x0714248f _ZN7WebCore11RenderBlock5paintERNS_9PaintInfoEii + 307
22  WebCore                             0x07141615 _ZN7WebCore11RenderBlock13paintChildrenERNS_9PaintInfoEii + 467
23  WebCore                             0x071420ab _ZN7WebCore11RenderBlock11paintObjectERNS_9PaintInfoEii + 403
24  WebCore                             0x0714248f _ZN7WebCore11RenderBlock5paintERNS_9PaintInfoEii + 307
25  WebCore                             0x07141615 _ZN7WebCore11RenderBlock13paintChildrenERNS_9PaintInfoEii + 467
26  WebCore                             0x071420ab _ZN7WebCore11RenderBlock11paintObjectERNS_9PaintInfoEii + 403
27  WebCore                             0x0714248f _ZN7WebCore11RenderBlock5paintERNS_9PaintInfoEii + 307
28  WebCore                             0x07141615 _ZN7WebCore11RenderBlock13paintChildrenERNS_9PaintInfoEii + 467
29  WebCore                             0x071420ab _ZN7WebCore11RenderBlock11paintObjectERNS_9PaintInfoEii + 403
30  WebCore                             0x0714248f _ZN7WebCore11RenderBlock5paintERNS_9PaintInfoEii + 307
31  WebCore                             0x071961b0 _ZN7WebCore11RenderLayer10paintLayerEPS0_PNS_15GraphicsContextERKNS_7IntRectEjPNS_12RenderObjectEPN3WTF7HashMapIPNS_24OverlapTestRequestClientES4_NS9_7PtrHashISC_EENS9_10HashTraitsISC_EENSF_IS4_EEEEj + 3684
32  WebCore                             0x0719648c _ZN7WebCore11RenderLayer10paintLayerEPS0_PNS_15GraphicsContextERKNS_7IntRectEjPNS_12RenderObjectEPN3WTF7HashMapIPNS_24OverlapTestRequestClientES4_NS9_7PtrHashISC_EENS9_10HashTraitsISC_EENSF_IS4_EEEEj + 4416
33  WebCore                             0x071973bb _ZN7WebCore11RenderLayer5paintEPNS_15GraphicsContextERKNS_7IntRectEjPNS_12RenderObjectE + 101
34  WebCore                             0x06bef809 _ZN7WebCore9FrameView13paintContentsEPNS_15GraphicsContextERKNS_7IntRectE + 591
35  WebKit                              0x067a51d0 -[WebFrame(WebInternal) _drawRect:contentsOnly:] + 368
36  WebKit                              0x067cc83c -[WebHTMLView drawSingleRect:] + 124
37  WebKit                              0x067cc786 -[WebHTMLView drawRect:] + 118
38  WebCore                             0x07392c2f _ZL12drawCallbackP6WKView6CGRectPv + 95
39  WebCore                             0x073cd52c _ZL11_WKViewDrawP9CGContextP6WKView6CGRectb + 492
40  WebCore                             0x073cd61f _ZL11_WKViewDrawP9CGContextP6WKView6CGRectb + 735
41  WebCore                             0x073cd61f _ZL11_WKViewDrawP9CGContextP6WKView6CGRectb + 735
42  WebCore                             0x073cd61f _ZL11_WKViewDrawP9CGContextP6WKView6CGRectb + 735
43  WebCore                             0x073cd61f _ZL11_WKViewDrawP9CGContextP6WKView6CGRectb + 735
44  WebCore                             0x073cd80e WKViewDisplayRect + 158
45  WebCore                             0x073cead0 WKWindowDrawRect + 48
46  WebCore                             0x0735daf0 _ZN7WebCore9TileCache9drawLayerEP9TileLayerP9CGContext + 880
47  WebCore                             0x07362af1 -[TileLayer drawInContext:] + 49
48  QuartzCore                          0x0417212d _ZL16backing_callbackP9CGContextPv + 88
49  QuartzCore                          0x0409215d CABackingStoreUpdate_ + 2636
50  QuartzCore                          0x04171fd2 _ZN2CA5Layer8display_Ev + 1370
51  QuartzCore                          0x0415fcf1 -[CALayer _display] + 33
52  QuartzCore                          0x04166281 _ZN2CA5Layer7displayEv + 165
53  QuartzCore                          0x0415fd17 -[CALayer display] + 33
54  QuartzCore                          0x04169c5c _ZN2CA5Layer17display_if_neededEPNS_11TransactionE + 256
55  QuartzCore                          0x040effb9 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 395
56  QuartzCore                          0x040f1ea6 _ZN2CA11Transaction6commitEv + 374
57  QuartzCore                          0x040f1580 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 80
58  CoreFoundation                      0x011959ce __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
59  CoreFoundation                      0x0112c670 __CFRunLoopDoObservers + 384
60  CoreFoundation                      0x010f84f6 __CFRunLoopRun + 1174
61  CoreFoundation                      0x010f7db4 CFRunLoopRunSpecific + 212
62  CoreFoundation                      0x010f7ccb CFRunLoopRunInMode + 123
63  GraphicsServices                    0x04789879 GSEventRunModal + 207
64  GraphicsServices                    0x0478993e GSEventRun + 114
65  UIKit                               0x02190a9b UIApplicationMain + 1175
66  ???                                 0x0cda47fd 0x0 + 215631869
67  ???                                 0x0cc78ea0 0x0 + 214404768
68  ???                                 0x0cc78b98 0x0 + 214403992
69  ???                                 0x0cc78cee 0x0 + 214404334
70  MyApp                               0x00009ff2 mono_jit_runtime_invoke + 722
71  MyApp                               0x00169eee mono_runtime_invoke + 126
72  MyApp                               0x0016dfd4 mono_runtime_exec_main + 420
73  MyApp                               0x001733f5 mono_runtime_run_main + 725
74  MyApp                               0x000671f5 mono_jit_exec + 149
75  MyApp                               0x002116c9 main + 2825
76  MyApp                               0x00003045 start + 53
   ==================================================== ================
   执行本机代码时获得 SIGSEGV。这通常表明
   单声道运行时或本机库之一中的致命错误
   由您的应用程序使用。
   ==================================================== ================

4

1 回答 1

1

这是一个Autocorrection反击的案例,也就是 bug # 325(还有很多重复),它不是MonoTouch特定的。

在内心深处,模拟的 iOS 被损坏并显示出来,而它想要绘制它的小红线以显示某些内容拼写错误。

只会在模拟器中发生,并且只有在UITextField启用了自动更正时才会发生。像这样关闭它:

new EntryElement("that contains spaces", string.Empty, string.Empty) {
    AutocorrectionType = UITextAutocorrectionType.No
}

将解决这个问题(你只能为你的模拟器构建使用 a #define)。

于 2012-02-20T20:48:52.303 回答