我正在使用 Xamarin Forms,我只在第一代 iPad Mini (iOS 9.3.3 (13G34)) 上看到这个问题。
该应用程序启动正常,点击内容正常。唯一的问题发生在我“点击并按住”按钮时,导致它崩溃。
错误消息的重要部分可能是这样的:
+[NSTimer scheduledTimerWithTimeInterval:repeats:block:]: unrecognized selector sent to class 0x3b101ed4
未处理的异常:Foundation.MonoTouchException:
现在这个 [SO answer][1] 指出 NSTimer 是一个 iOS10+ API,因此 iOS9 不被支持。
我的问题是如何在 Xamarin Forms 环境中修复它?
谢谢。
完整的错误消息文本:
2018-10-18 14:31:25.805 MyApp.iOS[319:59406] +[NSTimer scheduledTimerWithTimeInterval:repeats:block:]: unrecognized selector sent to class 0x3b101ed4
Unhandled Exception:
Foundation.MonoTouchException: <Timeout exceeded getting exception details>
Thread finished: <Thread Pool> #10
The thread 0xa has exited with code 0 (0x0).
Thread finished: <Thread Pool> #13
The thread 0xd has exited with code 0 (0x0).
2018-10-18 14:31:47.340 MyApp.iOS[319:59406]
Unhandled Exception:
0 MyApp.iOS 0x05941e01 setup_stack_trace + 128
1 MyApp.iOS 0x0594017f mono_handle_exception_internal + 2026
2 MyApp.iOS 0x0593f991 mono_handle_exception + 50
3 MyApp.iOS 0x05937837 mono_arm_throw_exception + 118
4 MyApp.iOS 0x0085ac4c throw_exception + 64
5 MyApp.iOS 0x05a88390 xamarin_process_managed_exception_gchandle + 60
6 MyApp.iOS 0x05a8834c xamarin_ftnptr_exception_handler + 24
at (wrapper native-to-managed) ObjCRuntime.Runtime.throw_ns_exception (intptr) [0x00025] in <572357c3f84340a29e439dbdac7629bd#91B547D7-180F-9262-A1A8-072C01C70687>:0
8 MyApp.iOS 0x05a86228 xamarin_throw_ns_exception + 52
9 MyApp.iOS 0x05a892b4 _ZL17exception_handlerP11NSException + 288
10 CoreFoundation
0x24157c57 <redacted> + 642
11 libobjc.A.dylib 0x238f309f <redacted> + 174
12 libc++abi.dylib 0x238e4e17 <redacted> + 78
13 libc++abi.dylib 0x238e48f9 __cxa_increment_exception_refcount + 0
14 libobjc.A.dylib 0x238f2f5f objc_exception_rethrow + 42
15 CoreFoundation 0x240672af CFRunLoopRunSpecific + 654
16 CoreFoundation 0x24067015 CFRunLoopRunInMode + 108
17 GraphicsServices 0x25657ac9 GSEventRunModal + 160
18 UIKit 0x2873b189 UIApplicationMain + 144
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) [0x0004f] in <572357c3f84340a29e439dbdac7629bd#91B547D7-180F-9262-A1A8-072C01C70687>:0
at UIKit.UIApplication.Main (string[],intptr,intptr) [0x00011] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/UIKit/UIApplication.cs:80
at UIKit.UIApplication
.Main (string[],string,string) [0x00034] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/UIKit/UIApplication.cs:64
at MyApp.iOS.Application.Main (string[]) [0x00001] in C:\Projects\MyProject\MyApp\MyApp.iOS\Main.cs:17
at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) [0x0001e] in <7d5a05cfcb09432d8cc656b9d781e54b#91B547D7-180F-9262-A1A8-072C01C70687>:0
24 MyApp.iOS 0x0594c9c9 mono_jit_runtime_invoke + 824
25 MyApp.iOS 0x059b6eef mono_runtime_invoke_checked + 102
26 MyApp.iOS 0x059bb6db mono_runtime_exec_main_checked + 66
27 MyApp.iOS 0x05934141 mono_jit_exec + 198
28 MyApp.iOS 0x05a9d174 xamarin_main + 2452
29 MyApp.iOS 0x002388bd main + 102
30 libdyld.dylib 0x23d0f873 <redacted> + 2
2018-10-18 14:31:47.344 MyApp.iOS[319:59406] Unhandled managed exception:
Objective-C exception thrown. Name: NSInvalidArgumentException Reason: +[NSTimer scheduledTimerWithTimeInterval:repeats:block:]: unrecognized selector sent to class 0x3b101ed4
Native stack trace:
0 CoreFoundation 0x24157933 <redacted> + 150
1 libobjc.A.dylib 0x238f2e17 objc_exception_throw + 38
2 CoreFoundation 0x2415d1d1 <redacted> + 0
3 CoreFoundation 0x2415aee1 <redacted> + 700
4 CoreFoundation 0x24086238 _CF_forwarding_prep_0 + 24
5 MyApp.iOS 0x02ae4e68 wrapper_managed_to_native_ObjCRuntime_Messaging_IntPtr_objc_msgSend_Double_bool_IntPtr_intptr_intptr_double_bool_intptr + 156
6 MyApp.iOS 0x025eb030 Foundation_NSTimer_CreateScheduledTimer_double_bool_System_Action_1_Foundation_NSTimer + 276
7 MyApp.iOS 0x058b39ec MyApp_Forms
_Controls_ExtendedButtonRenderer_OnLongPressed_UIKit_UILongPressGestureRecognizer + 1468
8 MyApp.iOS 0x0286d720 UIKit_UILongPressGestureRecognizer_Callback_Activated_UIKit_UILongPressGestureRecognizer + 52
9 MyApp.iOS 0x008014a4 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 232
10 MyApp.iOS 0x0594c9c9 mono_jit_runtime_invoke + 824
11 MyApp.iOS 0x059b6eef mono_runtime_invoke_checked + 102
12 MyApp.iOS 0x059b9ac1 mono_runtime_invoke + 56
13 MyApp.iOS 0x001e7119 _ZL32native_to_managed_trampoline_212P11objc_objectP13objc_selectorPP11_MonoMethodP28UILongPressGestureRecognizerj + 326
14 MyApp.iOS 0x001e6fcf -[__UILongPressGestureRecognizer target:] + 50
15 UIKit 0x28c389eb <redacted> + 142
16 UIKit 0x2887384f <redacted> +
170
17 UIKit 0x28704ff1 <redacted> + 1004
18 UIKit 0x28c39d4f <redacted> + 62
19 UIKit 0x286c5a57 <redacted> + 298
20 UIKit 0x286c2017 <redacted> + 2902
21 CoreFoundation 0x241196c9 <redacted> + 20
22 CoreFoundation 0x241179cd <redacted> + 280
23 CoreFoundation 0x24117dff <redacted> + 958
24 CoreFoundation 0x24067229 CFRunLoopRunSpecific + 520
25 CoreFoundation 0x24067015 CFRunLoopRunInMode + 108
26 GraphicsServices 0x25657ac9 GSEventRunModal + 160
27 UIKit 0x2873b189 UIApplicationMain + 144
28 MyApp.iOS 0x02bc227c wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 288
29 MyApp.iOS 0x02412044 UIKit_UIApplication_Main_stri
ng___intptr_intptr + 52
30 MyApp.iOS 0x02411edc UIKit_UIApplication_Main_string___string_string + 200
31 MyApp.iOS 0x0023acb0 MyApp_iOS_Application_Main_string__ + 152
32 MyApp.iOS 0x008014a4 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 232
33 MyApp.iOS 0x0594c9c9 mono_jit_runtime_invoke + 824
34 MyApp.iOS 0x059b6eef mono_runtime_invoke_checked + 102
35 MyApp.iOS 0x059bb6db mono_runtime_exec_main_checked + 66
36 MyApp.iOS 0x05934141 mono_jit_exec + 198
37 MyApp.iOS 0x05a9d174 xamarin_main + 2452
38 MyApp.iOS 0x002388bd main + 102
39 libdyld.dylib 0x23d0f873 <redacted> + 2
(Foundation.MonoTouchException)
at ObjCRuntime.Runtime.ThrowNSException (System.IntPtr ns_exception) [0x00000] in /Library/F
rameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/ObjCRuntime/Runtime.cs:398
at ObjCRuntime.Runtime.throw_ns_exception (System.IntPtr exc) [0x00000] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/runtime/Delegates.generated.cs:126
at (wrapper native-to-managed) ObjCRuntime.Runtime.throw_ns_exception(intptr)
--- End of stack trace from previous location where exception was thrown ---
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/UIKit/UIApplication.cs:63
at MyApp.iOS.Application.Main (Syst
em.String[] args) [0x00001] in C:\Projects\MyProjects\MyApp\MyApp.iOS\Main.cs:17
2018-10-18 14:31:47.346 MyApp.iOS[319:59406] critical: Stacktrace:
2018-10-18 14:31:47.346 MyApp.iOS[319:59406] critical:
Native stacktrace:
2018-10-18 14:31:50.337 MyApp.iOS[319:59406] critical: 0 MyApp.iOS 0x05940dfd mono_handle_native_crash + 196
2018-10-18 14:31:50.338 MyApp.iOS[319:59406] critical: 1 libsystem_platform.dylib 0x23e86077 _sigtramp + 42
2018-10-18 14:31:50.338 MyApp.iOS[319:59406] critical: 2 libsystem_pthread.dylib 0x23e8c733 pthread_kill + 62
2018-10-18 14:31:50.339 MyApp.iOS[319:59406] critical: 3 libsystem_c.dylib 0x23d770ad abort + 108
2018-10-18 14:31:50.339 MyApp.iOS[319:59406] critical: 4 MyApp.iOS 0x05a888b4 xamarin_printf + 0
2018-10-18 14:31:50.339 MyApp.iOS[319:59406] critical: 5 MyApp.iOS 0x0597bf1f mono_invoke_unhandled_exception_hook + 102
2018-10-18 14:31:50.340 MyApp.iOS[319:59406] critical: 6 MyApp.iOS 0x0594083b mono_handle_exception_internal + 3750
2018-10-18 14:31:50.340 MyApp.iOS[319:59406] critical: 7 MyApp.iOS 0x0593f991 mono_handle_exception + 50
2018-10-18 14:31:50.341 MyApp.iOS[319:59406] critical: 8 MyApp.iOS 0x05937837 mono_arm_throw_exception + 118
2018-10-18 14:31:50.341 MyApp.iOS[319:59406] critical: 9 MyApp.iOS 0x0085ac4c throw_exception + 64
2018-10-18 14:31:50.341 MyApp.iOS[319:59406] critical: 10 MyApp.iOS 0x05a88390 xamarin_process_managed_exception_gchandle + 60
2018-10-18 14:31:50.342 MyApp.iOS[319:59406] critical: 11 MyApp.iOS 0x05a8834c xamarin_ftnptr_exception_handler + 24
2018-10-18 14:31:50.342 MyApp.iOS[319:59406] critical: 12 MyApp.iOS 0x02bd4f14 wrapper_native_to_managed_ObjCRuntime_Runtime_throw_ns_exception_intptr + 372
2018-10-18 14:31:50.342 MyApp.iOS[319:59406] critical: 13 MyApp.iOS 0x05a86228 xamarin_throw_ns_exception + 52
2018-10-18 14:31:50.343 MyApp.iOS[319:59406] critical: 14 MyApp.iOS 0x05a892b4 _ZL17exception_handlerP11NSException + 288
2018-10-18 14:31:50.344 MyApp.iOS[319:59406] critical: 15 CoreFoundation 0x24157c57 <redacted> + 642
2018-10-18 14:31:50.344 MyApp.iOS[319:59406] critical: 16 libobjc.A.dylib 0x238f309f <redacted> + 174
2018-10-18 14:31:50.344 MyApp.iOS[319:59406] critical: 17 libc++abi.dylib 0x238e4e17 <redacted> + 78
2018-10-18 14:31:50.345 MyApp.iOS[319:59406] critical: 18 libc++abi.dylib 0x238e48f9 __cxa_increment_exception_refcount + 0
2018-10-18 14:31:50.345 MyApp.iOS[319:59406] critical: 19 libobjc.A.dylib 0x238f2f5f objc_exception_rethrow + 42
2018-10-18 14:31:50.345 MyApp.iOS[319:59406] critical: 20 CoreFoundation 0x240672af CFRunLoopRunSpecific + 654
2018-10-18 14:31:50.346 MyApp.iOS[319:59406] critical: 21 CoreFoundation 0x24067015 CFRunLoopRunInMode + 108
2018-10-18 14:31:50.346 MyApp.iOS[319:59406] critical: 22 GraphicsServices 0x25657ac9 GSEventRunModal + 160
2018-10-18 14:31:50.347 MyApp.iOS[319:59406] critical: 23 UIKit 0x2873b189 UIApplicationMain + 144
2018-10-18 14:31:50.347 MyApp.iOS[319:59406] critical: 24 MyApp.iOS 0x02bc227c wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 288
2018-10-18 14:31:50.348 MyApp.iOS[319:59406] critical: 25 MyApp.iOS 0x02412044 UIKit_UIApplication_Main_string___intptr_intptr + 52
2018-10-18 14:31:50.348 MyApp.iOS[319:59406] critical: 26 MyApp.iOS 0x02411edc UIKit_UIApplication_Main_string___string_string + 200
2018-10-18 14:31:50.349 MyApp.iOS[319:59406] critical: 27 MyApp.iOS 0x0023acb0 MyApp_iOS_Application_Main_string__ + 152
2018-10-18 14:31:50.350 MyApp.iOS[319:59406] critical: 28 MyApp.iOS 0x008014a4 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 232
2018-10-18 14:31:50.351 MyApp.iOS[319:59406] critical: 29 MyApp.iOS 0x0594c9c9 mono_jit_runtime_invoke + 824
2018-10-18 14:31:50.351 MyApp.iOS[319:59406] critical: 30 MyApp.iOS 0x059b6eef mono_runtime_invoke_checked + 102
2018-10-18 14:31:50.352 MyApp.iOS[319:59406] critical: 31 MyApp.iOS 0x059bb6db mono_runtime_exec_main_checked + 66
2018-10-18 14:31:50.352 MyApp.iOS[319:59406] critical: 32 MyApp.iOS 0x05934141 mono_jit_exec + 198
2018-10-18 14:31:50.352 MyApp.iOS[319:59406] critical: 33 MyApp.iOS 0x05a9d174 xamarin_main + 2452
2018-10-18 14:31:50.353 MyApp.iOS[319:59406] critical: 34 MyApp.iOS 0x002388bd main + 102
2018-10-18 14:31:50.353 MyApp.iOS[319:59406] critical: 35 libdyld.dylib 0x23d0f873 <redacted> + 2
2018-10-18 14:31:50.354 MyApp.iOS[319:59406] critical:
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
The app has been terminated.
Failed to Stop app: An error occured on client IDB4110776 while executing a reply for topic xvs/idb/4.11.0.776/stop-app
The app has been terminated.
[1]: https://stackoverflow.com/questions/40521799/trivial-nstimer-scheduledtimerwithtimeintervalrepeatsblock-unrecognized
最佳答案
可以使用方法
public static NSTimer CreateScheduledTimer (double seconds, NSObject target, Selector selector, NSObject userInfo, bool repeats)
For Example
//...
using ObjCRuntime;
//...
NSTimer.CreateScheduledTimer(0.5, this, new Selector("DelayAction"), null, false);
[Export("DelayAction")]
public void DelayAction()
{
// do some thing you want
}
关于ios - 未处理的异常 : Foundation. MonoTouchException:<超时获取异常详细信息>发生,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52883087/
大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
Rackup通过Rack的默认处理程序成功运行任何Rack应用程序。例如:classRackAppdefcall(environment)['200',{'Content-Type'=>'text/html'},["Helloworld"]]endendrunRackApp.new但是当最后一行更改为使用Rack的内置CGI处理程序时,rackup给出“NoMethodErrorat/undefinedmethod`call'fornil:NilClass”:Rack::Handler::CGI.runRackApp.newRack的其他内置处理程序也提出了同样的反对意见。例如Rack
我有一个对象has_many应呈现为xml的子对象。这不是问题。我的问题是我创建了一个Hash包含此数据,就像解析器需要它一样。但是rails自动将整个文件包含在.........我需要摆脱type="array"和我该如何处理?我没有在文档中找到任何内容。 最佳答案 我遇到了同样的问题;这是我的XML:我在用这个:entries.to_xml将散列数据转换为XML,但这会将条目的数据包装到中所以我修改了:entries.to_xml(root:"Contacts")但这仍然将转换后的XML包装在“联系人”中,将我的XML代码修改为
关闭。这个问题需要detailsorclarity.它目前不接受答案。想改进这个问题吗?通过editingthispost添加细节并澄清问题.关闭8年前。Improvethisquestion在首页我有:汽车:VolvoSaabMercedesAudistatic_pages_spec.rb中的测试代码:it"shouldhavetherightselect"dovisithome_pathit{shouldhave_select('cars',:options=>['volvo','saab','mercedes','audi'])}end响应是rspec./spec/request
我正在学习Rails,并阅读了关于乐观锁的内容。我已将类型为integer的lock_version列添加到我的articles表中。但现在每当我第一次尝试更新记录时,我都会收到StaleObjectError异常。这是我的迁移:classAddLockVersionToArticle当我尝试通过Rails控制台更新文章时:article=Article.first=>#我这样做:article.title="newtitle"article.save我明白了:(0.3ms)begintransaction(0.3ms)UPDATE"articles"SET"title"='dwdwd
有没有办法在这个简单的get方法中添加超时选项?我正在使用法拉第3.3。Faraday.get(url)四处寻找,我只能先发起连接后应用超时选项,然后应用超时选项。或者有什么简单的方法?这就是我现在正在做的:conn=Faraday.newresponse=conn.getdo|req|req.urlurlreq.options.timeout=2#2secondsend 最佳答案 试试这个:conn=Faraday.newdo|conn|conn.options.timeout=20endresponse=conn.get(url
在Cooper的书BeginningRuby中,第166页有一个我无法重现的示例。classSongincludeComparableattr_accessor:lengthdef(other)@lengthother.lengthenddefinitialize(song_name,length)@song_name=song_name@length=lengthendenda=Song.new('Rockaroundtheclock',143)b=Song.new('BohemianRhapsody',544)c=Song.new('MinuteWaltz',60)a.betwee
这里有一个很好的答案解释了如何在Ruby中下载文件而不将其加载到内存中:https://stackoverflow.com/a/29743394/4852737require'open-uri'download=open('http://example.com/image.png')IO.copy_stream(download,'~/image.png')我如何验证下载文件的IO.copy_stream调用是否真的成功——这意味着下载的文件与我打算下载的文件完全相同,而不是下载一半的损坏文件?documentation说IO.copy_stream返回它复制的字节数,但是当我还没有下
我使用Nokogiri(Rubygem)css搜索寻找某些在我的html里面。看起来Nokogiri的css搜索不喜欢正则表达式。我想切换到Nokogiri的xpath搜索,因为这似乎支持搜索字符串中的正则表达式。如何在xpath搜索中实现下面提到的(伪)css搜索?require'rubygems'require'nokogiri'value=Nokogiri::HTML.parse(ABBlaCD3"HTML_END#my_blockisgivenmy_bl="1"#my_eqcorrespondstothisregexmy_eq="\/[0-9]+\/"#FIXMEThefoll