iphone - iPhone 中可编辑的 UIWebView

标签 iphone

我看过一些关于使 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]];

无论如何,我建议阅读本教程,因为它还展示了如何执行其他操作(更改字体、颜色、嵌入图像等)

关于iphone - iPhone 中可编辑的 UIWebView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4008250/

相关文章:

ios - iOS10 上语音转文字?

iphone - UITextField 中的问题在 iPhone 的 UIImageView 中添加?

ios - 在 iPhone objective-c 上的 AVPlayer 中添加字幕

iphone - 分发配置文件待定

iphone - 如何为 iOS 4 编译和使用 CommonCrypto?

ios - 自动旋转在 iOS 7 中不起作用,在 iOS 6 中工作正常

ios - 内部分布概况

ios - 基于从特定 TableView 中分离出来执行特定操作(如设置 UIDatePicker 的日期)

iphone - 无法将对象添加到返回 nil 的可变数组

iphone - UIWindow 在哪里实例化,storyboard 传入?