0
我的应用程序基本上是一个web浏览器和本地存储的web应用程序。快速简单的应用程序总是在模拟器上崩溃
为了支持URL的方案映射,我呼吁viewDidLoad
以下功能,订阅UIApplicationDidBecomeActiveNotification
,然后当我得到这样的消息,我打开一个web应用到UIWebView
:
/**
* Setup the observer to get notifications about app activation
*/
func initObserver() {
NSNotificationCenter.defaultCenter().addObserver(
self,
selector: "initWebApp",
name: UIApplicationDidBecomeActiveNotification,
object: nil);
}
/**
* Launches the WebApp, this is called from the observer,
* and appDelegate.appParameters has possible parameters to the webapp
*/
func initWebApp() {
var appDelegate=UIApplication.sharedApplication().delegate as AppDelegate;
println ("- Launch Parameters: "+appDelegate.initParameters);
let path=appDelegate.initParameters,
url=NSURL(string: URL_BASE + "?" + (path ?? "")),
requestObj=NSURLRequest(URL: url!);
mWebView.loadRequest(requestObj);
}
然而,当我以这种方式初始化webview(来自观察处理程序)时,只要单击窗口上的任何位置,模拟器就会始终与下面包含的堆栈跟踪一起崩溃。
相反,如果我不同意的情况下,并调用initWebApp()
从viewDidLoad()
,一切工作正常(显然URL方案的映射不工作,但我的意思是的WebView及其应用工作100%没有崩溃)
任何人都可以看看这个堆栈跟踪(它总是相同的),并给我任何指针?
从事件处理程序操作UIWebView等UI对象是否是一种不好的做法? (我来自Android的,你经常要更改线程在类似情况下)
2015-04-06 02:49:34.907 FunqTV[14285:518122] -[NSURL _effectiveStatusBarStyleViewController]: unrecognized selector sent to instance 0x7ae1cac0
2015-04-06 02:49:34.919 FunqTV[14285:518122] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSURL _effectiveStatusBarStyleViewController]: unrecognized selector sent to instance 0x7ae1cac0'
*** First throw call stack:
*** First throw call stack:
(
0 CoreFoundation 0x00648466 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x02037a97 objc_exception_throw + 44
2 CoreFoundation 0x006502c5 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277
3 CoreFoundation 0x00598bc7 ___forwarding___ + 1047
4 CoreFoundation 0x0059878e _CF_forwarding_prep_0 + 14
5 UIKit 0x00fd3fa8 +[UIViewController _currentStatusBarStyleViewController] + 75
6 UIKit 0x00e63c81 -[UIApplication _updateCurrentStatusBarViewControllerAppearance] + 59
7 UIKit 0x00eb06ea -[UIWindow _updateContextOrderingAndSetLayerHidden:] + 548
8 UIKit 0x00eade74 -[UIWindow _initWithFrame:debugName:scene:attached:] + 336
9 UIKit 0x00eadd1e -[UIWindow _initWithFrame:debugName:attached:] + 79
10 UIKit 0x00eadc7f -[UIWindow _initWithFrame:attached:] + 71
11 UIKit 0x011e6f27 -[UIAutoRotatingWindow _initWithFrame:attached:] + 80
12 UIKit 0x00eadc33 -[UIWindow initWithFrame:] + 63
13 UIKit 0x011e6eba -[UIAutoRotatingWindow initWithFrame:] + 72
14 UIKit 0x011e4e2a -[UITextEffectsWindow initWithFrame:] + 72
15 UIKit 0x00eae09a -[UIWindow initWithContentRect:] + 164
16 UIKit 0x011e4b12 -[UITextEffectsWindow(UIObjectsForPerScreen) _basicInitWithScreen:options:] + 141
17 UIKit 0x011e4bcf -[UITextEffectsWindow(UIObjectsForPerScreen) _initWithScreen:options:] + 182
18 UIKit 0x016fcf8c +[_UIObjectPerScreen objectOfClass:forScreen:withOptions:createIfNecessary:] + 556
19 UIKit 0x011e645c +[UITextEffectsWindow _sharedTextEffectsWindowforScreen:aboveStatusBar:allowHosted:matchesStatusBarOrientationOnAccess:] + 416
20 UIKit 0x011e65b4 +[UITextEffectsWindow sharedTextEffectsWindowForScreen:] + 121
21 UIKit 0x013d173a -[UIPeripheralHost(UIKitInternal) containerWindow] + 156
22 UIKit 0x013d178a -[UIPeripheralHost(UIKitInternal) containerRootController] + 34
23 UIKit 0x013c6e15 -[UIPeripheralHost currentState] + 38
24 UIKit 0x013c6f10 -[UIPeripheralHost isOnScreen] + 35
25 UIKit 0x013d3a6a -[UIPeripheralHost(UIKitInternal) _isCoordinatingWithSystemGestures] + 82
26 UIKit 0x00e70da1 -[UIApplication _shouldDelayTouchesForControlCenter] + 56
27 UIKit 0x00ebd506 -[UIWindow _shouldDelayTouchForSystemGestures:] + 41
28 UIKit 0x0128f8e8 -[_UISystemGestureGateGestureRecognizer touchesBegan:withEvent:] + 498
29 UIKit 0x00eb3946 -[UIWindow _sendGesturesForEvent:] + 567
30 UIKit 0x00eb4abf -[UIWindow sendEvent:] + 769
31 UIKit 0x00e79bb1 -[UIApplication sendEvent:] + 242
32 UIKit 0x00e89bf6 _UIApplicationHandleEventFromQueueEvent + 21066
33 UIKit 0x00e5dbc7 _UIApplicationHandleEventQueue + 2300
34 CoreFoundation 0x0056b98f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
35 CoreFoundation 0x0056149d __CFRunLoopDoSources0 + 253
36 CoreFoundation 0x005609f8 __CFRunLoopRun + 952
37 CoreFoundation 0x0056037b CFRunLoopRunSpecific + 443
38 CoreFoundation 0x005601ab CFRunLoopRunInMode + 123
39 GraphicsServices 0x040152c1 GSEventRunModal + 192
40 GraphicsServices 0x040150fe GSEventRun + 104
41 UIKit 0x00e619b6 UIApplicationMain + 1526
42 FunqTV 0x0007dfbe top_level_code + 78
43 FunqTV 0x0007dffb main + 43
44 libdyld.dylib 0x027a5ac9 start + 1
45 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
你是对的先生!添加它 – rupps 2015-04-06 01:05:49
难道是我创建组来整理项目文件并将info.plist和storyboard移动到一个组?在做之前,一切都在起作用。编辑:与故事板和项目文件的PNG – rupps 2015-04-06 01:11:20
嘿马特我发现这个问题,显然我必须包装调用来初始化webview在dispatch_async()块,如果来自观察员。谢谢你的帮助! – rupps 2015-04-06 02:44:14