4

いくつかの html コンテンツを にロードしていUIWebViewます。内容はこんな感じ

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

この部分は正常に動作します。iOS5.0以降対応のcontentEditableプロパティを使用しています。UIWebViewコンテンツを

<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オブジェクトが含まれているか、オブジェクトが含まれていません。どんな指針でも大歓迎ですか?

ここに画像の説明を入力

4

1 に答える 1

2

次のコードを使用して、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

于 2013-01-03T09:38:12.053 に答える