PhoneGap中文网
标题: 原生页面和H5页面跳转崩溃问题 [打印本页]
作者: hanyutong 时间: 2016-4-18 13:55
标题: 原生页面和H5页面跳转崩溃问题
从原生页面跳转到H5页面后,在页面未加载完后返回原生页面。
原生页面 到H5的跳转是push出来的。
H5 跳转回原生页面 是写了一个插件,将H5页面pop出去。
会出现崩溃现象,检查了 代理等 均会在所继承的父类CDVViewController中移除。
报错如下:
2016-04-18 11:29:59.828 TB[6605:2578321] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance 0x1291e55a0 of class UIView was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x129336740> (
<NSKeyValueObservance 0x12908d840: Observer: 0x1290ca140, Key path: frame, Options: <New: NO, Old: NO, Prior: NO> Context: 0x0, Property: 0x127e43230>
<NSKeyValueObservance 0x1292f41b0: Observer: 0x1290ca140, Key path: bounds, Options: <New: NO, Old: NO, Prior: NO> Context: 0x0, Property: 0x12938e080>
)'
*** First throw call stack:
(0x18164d900 0x180cbbf80 0x18164d848 0x181f8f5c0 0x180cd5ae8 0x18153142c 0x181602a20 0x181531680 0x182a40088 0x1863a8d90 0x1000d82f0 0x1810d28b8)
libc++abi.dylib: terminating with uncaught exception of type NSException
下面 是相关的插件及加载H5页面的类
插件类:
- #import "xzWindows.h"
- #import "XTBHtmlViewController.h"
- @implementation xzWindows
- #pragma mark - 从Native跳转到Html/ 从Html跳转到Native
- -(void)nativeJumpToHtml:(CDVInvokedUrlCommand *)command
- {
- /*
- NSString* _callbackId; 回调id
- NSString* _className; 类名
- NSString* _methodName; 方法名
- NSArray* _arguments; 参数
- */
-
- [[NSNotificationCenter defaultCenter] postNotificationName:@"StartPageWithHtml" object:nil userInfo:@{@"startPage":command.arguments[0]}];
- DLog(@"???");
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
- }
- - (void)close:(CDVInvokedUrlCommand*)command;
- {
- [[NSNotificationCenter defaultCenter] postNotificationName:@"HtmlBackToNative" object:nil userInfo:nil];
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
- }
- @end
复制代码
加载H5页面的类,已继承 CDVViewController
XTBMessageNoticeViewController.h
- //
- // XTBMessageNoticeViewController.h
- // TB
- //
- // Created by hanyutong on 16/3/4.
- //
- //
- #import <Cordova/CDVViewController.h>
- #import <Cordova/CDVCommandDelegateImpl.h>
- #import <Cordova/CDVCommandQueue.h>
- @interface XTBHtmlViewController : CDVViewController
- @end
- @interface HtmlCommandDelegate : CDVCommandDelegateImpl
- @end
- @interface HtmlCommandQueue : CDVCommandQueue
- @end
复制代码
XTBMessageNoticeViewController.m
作者: ionicwang 时间: 2016-4-19 09:51
找个懂原生的问问,不懂原生
欢迎光临 PhoneGap中文网 (http://bbs.phonegap100.com/) |
Powered by Discuz! X3.2 |