Reputation: 4935
With UIWebView, I can display HTML very well. With UITextView, I can edit HTML. With what can I both display and edit HTML?
Is there any open source project or tutorial available?
Upvotes: 1
Views: 3622
Reputation: 4523
check this lib which is updated and can be used above ios 11 and written in swift
-AztecEditor link
-updated version of
RichEditorView
link
Upvotes: -1
Reputation: 27354
You can show your html inside a UIWebView
with a WYSIWYG editor inside. There are a lot of WYSIWYG editors out there. I like CKEditor (demo).
See the Developer Documentation - Integration for how to set / get the text of the WYSIWYG editor.
<head> ... <script type="text/javascript" src="/ckeditor/ckeditor.js"></script> </head>
<textarea id="editor1" name="editor1"> <p>Initial value.</p> </textarea>
<script type="text/javascript"> CKEDITOR.replace( 'editor1' ); </script>
Use the script:
var editor_data = CKEDITOR.instances.editor1.getData();
You can use UIWebView
's stringByEvaluatingJavaScriptFromString:
method to run javascript code to get / set the html content as needed.
Upvotes: 3
Reputation: 5591
Have you tried using the UITextViewDelegate
method (such as textViewDidChange:
) and reload the content of the UITextView
's text
property back into the UIWebView
(using loadHTMLString:baseURL:
)?
- (void)textViewDidChange:(UITextView *)textView {
[self.webView loadHTMLString:textView.text baseURL:nil];
}
This will allow you to manually amend HTML and see the result.
Upvotes: 0