【问题标题】:How to embed WebView inside InputView For IOS custom keyboard app extensionIOS自定义键盘应用扩展如何在InputView中嵌入WebView
【发布时间】:2016-12-20 05:58:00
【问题描述】:

我尝试创建一个故事板,其中嵌入了 webview 然后在 ViewController 控制器类中,在 viewDidLoad 方法中:

[self.myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.google.com"]]];

日志:


CustomKeyboard[1865:37706] [Common] BKSAccelerometer 无法为设备方向创建通知令牌

CustomKeyboard[1865:37779] [default] 注册通知端口时出错:(1000000)

CustomKeyboard[1865:37706] [] __nwlog_err_simulate_crash_libsystem libsystem 模拟崩溃失败“libsystem_network.dylib: networkd_settings_setup_notify_watch :: notify_register_dispatch(com.apple.system.networkd.settings) [status 1000000] 失败”

CustomKeyboard[ 1865:37706] [] networkd_settings_setup_notify_watch notify_register_dispatch(com.apple.system.networkd.settings) [status 1000000] 失败,转储回溯:
[arm64] libnetcore-856.1.8
0 libsystem_network.dylib 0x0000000188db5534 __nw_create_backtrace_string + 116
1 libsystem_network.dylib 0x0000000188dd17e4 + 332
2 libsystem_network.dylib 0x0000000188dd15b0 + 68
3 libsystem_network.dylib 0x0000000188da91a8 nwlog_is_debug_logging_enabled + 32
4 libsystem_network.dylib 0x0000000188dc8fac + 256
5 libsystem_network.dylib 0x0000000188dc917c + 24
6 libdispatch.dylib 0x0000000188c051c0 + 16
7 libdispatch.dylib 0x0000000188c12860 + 84
8 libsystem_network.dylib 0x0000000188dc7088 + 160
9 libsystem_network.dylib 0x0000000188dc6b1c + 136
10 libsy

CustomKeyboard[1865:37706] [] __nwlog_err_simulate_crash_libsystem libsystem 模拟崩溃失败“libsystem_network.dylib: networkd_settings_init :: notify_register_check(nw_notification_name_settings) 状态 1000000 令牌 -1 失败”

CustomKeyboard[1865: 37706] [] networkd_settings_init notify_register_check(nw_notification_name_settings) 状态 1000000 令牌 -1 失败,转储回溯:
[arm64] libnetcore-856.1.8
0 libsystem_network.dylib 0x0000000188db5534 __nw_create_backtrace_string + 116
1 libsystem_network.dylib 0x0000000188dd1620 + 180
2 libsystem_network.dylib 0x0000000188da91a8 nwlog_is_debug_logging_enabled + 32
3 libsystem_network.dylib 0x0000000188dc8fac + 256
4 libsystem_network.dylib 0x0000000188dc917c + 24
5 libdispatch.dylib 0x0000000188c051c0 + 16
6 libdispatch.dylib 0x0000000188c12860 + 84
7 libsystem_network.dylib 0x0000000188dc7088 + 160
8 libsystem_network.dylib 0x0000000188dc6b1c + 136
9 libsystem_network.dylib 0x0000000188dc68c4 nw_path_create_evaluator_for_endpoint + 972


CustomKeyboard[1865:37912] dnssd_clientstub ConnectToServer:connect()-> 尝试次数:1

CustomKeyboard[1865:37912] dnssd_clientstub ConnectToServer : connect()-> 尝试次数:2

CustomKeyboard[1865:37912] dnssd_clientstub ConnectToServer:connect()-> 尝试次数:3

CustomKeyboard[1865:37912] dnssd_clientstub ConnectToServer : connect() 失败路径:/var/run/mDNSResponder 套接字:5 Err:-1 Errno:1 不允许操作

CustomKeyboard[1865:37912] [] nw_resolver_create_dns_service_on_queue DNSServiceCreateConnection 失败:ServiceNotRunning(-65563)
CustomKeyboard[1865:37945] [] __nw_connection_get_connected_socket_block_invoke 2 连接没有连接的处理程序

CustomKeyboard[1865:37929] PAC 流失败

CustomKeyboard[1865:37929] [] nw_proxy_resolver_create_parsed_array PAC 评估错误:kCFErrorDomainCFNetwork:-7200 0

CustomKeyboard[1865:37929] dnssd_clientstub ConnectToServer:connect()-> 尝试次数:1

CustomKeyboard[1865:37929] dnssd_clientstub ConnectToServer:connect()-> 尝试次数: 2

CustomKeyboard[1865:37929] dnssd_clientstub ConnectToServer:connect()-> 尝试次数:3

CustomKeyboard[1865:37929] dnssd_clientstub ConnectToServer:connect() 失败路径:/var/运行/mDNSResponder 套接字:5 错误:-1 错误:1 不允许操作

CustomKeyboard[1865:37929] [] nw_resolver_create_dns_service_on_queue DNSServiceCreateConnection 失败:ServiceNotRunning(-65563)

【问题讨论】:

  • 我在尝试将联系人视图控制器嵌入自定义键盘时遇到了类似的问题。您的模拟器/测试设备是什么 iOS 版本?
  • 我在 ios 10 上测试它
  • 您找到解决方案了吗?
  • 运气好吗@ShubhamJha ?也有这个问题
  • 尝试以下解决方案

标签: ios webview custom-keyboard


【解决方案1】:

将代码放在 viewDidAppear 方法 中,而不是 viewDidLoad 方法中

- (void)viewDidAppear:(BOOL)animated { CGRect screenRect = [[UIScreen mainScreen] bounds]; CGFloat screenWidth = screenRect.size.width; //CGFloat screenHeight = screenRect.size.height; UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, screenWidth, 800)]; NSString *urlString = @"http://mum00blf.in.oracle.com:7777/index/public/login.html"; NSURL *url = [NSURL URLWithString:urlString]; NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url]; [webView loadRequest:urlRequest]; /*dispatch_async(dispatch_get_main_queue(), ^(void){ [self.view addSubview:webView]; });*/ [self.view addSubview:webView]; }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-04-06
    • 1970-01-01
    • 2015-08-05
    • 1970-01-01
    • 2015-05-30
    • 2014-11-27
    • 1970-01-01
    相关资源
    最近更新 更多