iphone - HTML 未正确加载

标签 iphone html objective-c ios uiwebview

我有 10 个 html 存储在一个数组中...我想通过单击按钮显示每个 html...但是我的应用程序崩溃了..这是代码..

int xpos=10,ypos=10;

for (int i=0; i<[array count]; i++) {

    UIButton *but=[UIButton buttonWithType:UIButtonTypeRoundedRect];
    [but setTag:i];
    but.backgroundColor=[UIColor redColor];
    but.frame=CGRectMake(xpos, ypos, 50, 50);
    xpos+=90;

    [self.view addSubview:but];
    [but addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchDown];
}


- (void)buttonClicked:(UIButton *)sender {

    NSString *str=[array objectAtIndex:sender.tag];
    [webview loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:str ofType:@"html"]isDirectory:NO]]];
    [webview release];
}

如何克服这个问题?这是崩溃报告

24/10/11 4:56:08 PM 正在加载 HTML[4655] * 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“* -[NSURL initFileURLWithPath:isDirectory:]:无字符串参数'

最佳答案

你在哪里初始化 WebView ?

请删除 [webview release]; 并立即尝试。

关于iphone - HTML 未正确加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7874701/

相关文章:

css - iOS 上的 Safari 在使用 background-clip 和 text-fill-color 结合一些伪元素时不显示文本

ios - 在 iOS 中以透明方式播放视频

php - $_GET 和 $_POST

objective-c - 如何检查 NSMutableArray 中是否存在对象

iOS [Obj-C] - 滚动时导航栏透明且项目可见

html - 表格行填充剩余高度 Chrome vs. Firefox

html - 使下拉菜单(绝对位置)增加父级高度

objective-c - 访问应用程序包中的 plist 返回 null

ios - 特定索引后字符的出现

iphone - VoiceOver 忽略可见 View ,并说出隐藏 View 的可访问性标签