gpt4 book ai didi

ios - SplitViewController 应用程序在加载 webview 时崩溃

转载 作者:行者123 更新时间:2023-11-29 13:36:41 25 4
gpt4 key购买 nike

我正在开发一个应用程序,该应用程序使用从 sqlite 数据库加载 html 文件的 splitViewController。我有一个做同样事情的 iphone 应用程序。它用数据库内容加载一个 TableView ,然后在用户触摸一个单元格时将一个 web View 推送到堆栈上。一切都适用于 iPhone 应用程序,但不适用于 iPad 的 splitViewController。一切正常,除了加载 webview 时。

这是头文件中的相关代码:

    #import <UIKit/UIKit.h>

@class LIDetailViewController;

@interface LIMasterViewController : UITableViewController <UISearchBarDelegate>{

@property (strong, nonatomic) LIDetailViewController *detailViewController;

在实现文件中:

@synthesize detailViewController = _detailViewController;

这是它崩溃的代码:

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
if (!_detailViewController) {
_detailViewController = [[LIDetailViewController alloc] initWithNibName:@"LIDetailViewController" bundle:nil];
}
[self.navigationController pushViewController:self.detailViewController animated:YES];
}


NSString *sqlData = [animal description];
NSString *htmlHead = @"<head><link type='text/css' rel='stylesheet' href='default.css'><head/><body><div class='content'>";
NSString *htmlBody = [sqlData stringByAppendingString:@"</div>"];
NSString *html = [htmlHead stringByAppendingString:htmlBody];
[_detailViewController.animalDescripton loadHTMLString:html baseURL:nil];

它在以下行崩溃:

[_detailViewController.animalDescripton loadHTMLString:html baseURL:nil];

这是调试器中的错误:“[UINavigationController animalDescripton]:无法识别的选择器发送到实例 0x685fa70”

如果有人能帮我解决这个问题那就太好了!提前致谢。

最佳答案

在 iPad 上,您显然从未设置过 self.detailViewController,因此它似乎默认为 UINavigationController

关于ios - SplitViewController 应用程序在加载 webview 时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10419205/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com