how to insert UIImage into UITextView

后端 未结 3 1277
梦谈多话
梦谈多话 2021-02-20 11:27

im working on a editable notebook type project. it consists some text and images at any time. in UITextView if we add images as subview the frames are fixed. but

3条回答
  •  长发绾君心
    2021-02-20 11:41

    I know it's too late.
    As per my understanding, you can use UIWebView to insert text and images both.
    Create an HTML file and put it in app bundle. Set the attribute of div or paragraph(in HTML) as contentEditable = "true". And load that file:-

    NSBundle *bundle = [NSBundle mainBundle];
    NSURL *indexFileURL = [bundle URLForResource:@"Index" withExtension:@"html"]; // HTML file name is "Index"
    [YourWebView loadRequest:[NSURLRequest requestWithURL:indexFileURL]];
    

    This way, your UIWebView becomes editable and you can insert text and image both.

    Edit:- Please have a look at this link:- Adding Images to UITextView

提交回复
热议问题