gpt4 book ai didi

iphone - UIWebView contentEditable 图像复制粘贴崩溃 (EXC_BAD_ACCESS)

转载 作者:可可西里 更新时间:2023-11-01 05:56:43 26 4
gpt4 key购买 nike

我正在 UIWebView 中加载一些 html 内容。内容看起来像这样

<img alt="" src="/image/968" style="width: 75px; height: 26px;">qweqwwqeqwe<img src="/image/969" width="32" height="32"></p>

这部分工作正常。我正在使用从 iOS5.0 开始支持的 UIWebViewcontentEditable 属性。我将内容包装在一个

<div contentEditable="true">mycontent</div>.

我能够编写/复制文本等。但是当我尝试从 webView 选择并复制图像并将其粘贴到下一行时,我的应用程序崩溃了(EXC_BAD_ACCESS )。我在 iPad 1 上运行 iOS 5.1.1。我试过检查

 [[UIPasteboard generalPasteboard] image]
[[UIPasteboard generalPasteboard] images]

[[UIPasteboard generalPasteboard] url]
[[UIPasteboard generalPasteboard] urls]

但在我复制图像并检查它们之后,它们总是null 或包含零对象。任何指针将不胜感激?

enter image description here

最佳答案

我使用以下代码将 html 字符串加载到 webView 中并对其进行编辑。它运行良好。

#import "WebViewEditViewController.h"

@interface WebViewEditViewController ()

@end

@implementation WebViewEditViewController

- (void)viewDidLoad
{
NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];

NSString *htmlString=@"<html><body><div contentEditable=\"true\"><img alt=\"\" src=\"1.jpg\" style=\"width: 100px; height: 100px;\">qweqwwqeqwe<img src=\"2.jpg\" width=\"150px\" height=\"70px\"></p></div></body></html>";
[_webView loadHTMLString:htmlString baseURL:baseURL];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end

我尝试在复制后打印日志,发现 [[UIPasteboard generalPasteboard] image] 在两种情况下都粘贴了 null,而代码工作正常。

关于iphone - UIWebView contentEditable 图像复制粘贴崩溃 (EXC_BAD_ACCESS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13891553/

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