我看过一些关于使UIWebView可编辑的文章.我希望能够以所见即所得的方式撰写包含文本和图像的消息,我想我可以使用UIWebView来完成它.
这是一个很好的解决方案,我该怎么做?我在网上搜索了一些例子,但没有找到.
谢谢
UIWebView 从iOS 5.0+开始,内容可以编辑.
可以在这里查看一个非常好的教程:http://ios-blog.co.uk/tutorials/rich-text-editing-a-simple-start-part-1/
本教程超越了这个问题,所以这里有一个如何使UIWebView可编辑的简历:
//index.html
<html>
<body>
<div id="content" contenteditable="true" style="font-family: Helvetica">This is out Rich Text Editing View </div>
</body>
</html>
//somewhere.m
NSBundle *bundle = [NSBundle mainBundle];
NSURL *indexFileURL = [bundle URLForResource:@"index" withExtension:@"html"];
[webView loadRequest:[NSURLRequest requestWithURL:indexFileURL]];
Run Code Online (Sandbox Code Playgroud)
无论如何,我建议阅读教程,因为它显示了如何做其他的东西(改变字体,颜色,嵌入图像等)