cjwirth / RichEditorView

RichEditorView is a simple, modular, drop-in UIView subclass for Rich Text Editing.
BSD 3-Clause "New" or "Revised" License
1.9k stars 445 forks source link

TMS-90809: Deprecated API Usage - Apple will stop accepting submissions of apps that use UIWebView APIs . See https://developer.apple.com/documentation/uikit/uiwebview for more information. After you’ve corrected the issues, you can use Xcode or Application Loader to upload a new binary to App Store Connect. #210

Open mehroozkhanpl opened 5 years ago

mehroozkhanpl commented 5 years ago

I solved this by Using WKWebView. You can check this link and update your code. "https://gist.github.com/fabfelici/f16f1ce54f00512db7e9ff87270a68f4"

farhanshaikh202 commented 5 years ago

I solved this by Using WKWebView. You can check this link and update your code. "https://gist.github.com/fabfelici/f16f1ce54f00512db7e9ff87270a68f4"

its an html

how to use RichEditorView without UIWebView

az-oolloow commented 5 years ago

@mehroozkhanpl did you mean this one? https://gist.github.com/fabfelici/837037f7737dc24765fe3035b15255ce

mehroozkhanpl commented 5 years ago

I solved this by Using WKWebView. You can check this link and update your code. "https://gist.github.com/fabfelici/f16f1ce54f00512db7e9ff87270a68f4"

its an html

how to use RichEditorView without UIWebView

I add library file direct to project. removed pod. and then edit RichEditorView.swift file

mehroozkhanpl commented 5 years ago

@mehroozkhanpl did you mean this one? https://gist.github.com/fabfelici/837037f7737dc24765fe3035b15255ce

yes Bro

mehroozkhanpl commented 5 years ago

I solved this by Using WKWebView. You can check this link and update your code. "https://gist.github.com/fabfelici/f16f1ce54f00512db7e9ff87270a68f4"

its an html

how to use RichEditorView without UIWebView

"https://gist.github.com/fabfelici/837037f7737dc24765fe3035b15255ce"

DrashtiJaviya-Openxcell commented 4 years ago

Hello @mehroozkhanpl

The solution you gave above didn't work for me. Could you please share your code if you have solve the issue? It would be of great help. Thanks in advance.

az-oolloow commented 4 years ago

I tried the above and that code is not even from this editor.

So far in googling this seems to be the most promising fork, installing it right now :) https://github.com/cbess/RichEditorView

DrashtiJaviya-Openxcell commented 4 years ago

Hello @az-oolloow Thanks for reply. But using your code toolbar is not shown and same issue face in your sample app also.Could you please share your code with display with toolbar options.

az-oolloow commented 4 years ago

@DrashtiJaviya-Openxcell Firstly, the above is not my code :) it is done by @cbess.

Secondly, he provides a toolbar option that works on iOS 13.

And finally, i never used that anyway, i add the toolbar as a subview with Auto Layout (because it derives from UIView this works okay).

That code is WKWebView based and just worked for me out of the box.

YoomamaFTW commented 4 years ago

Edit 11/28/2019: Refer to #223 for update for Swift 5 which'll include some additional code and directions.

Sample works fine for me; toolbar shown. Although, the iPhone 11 Pro Max simulator isn't the best since the text is going out of view (i.e. not wrapping around but instead, like terminal/cmd, just continuously typing horizontally). On my iPhone 6s, iOS 13.1, the text wraps and the sample application works perfectly fine, including in dark mode.

Note on Dark Mode: If you're using the sample code and access the color changer on the toolbar, the colored texts remains true to its state while the regular text uses dark mode enabled semantics. For example, the regular text, with dark mode disabled and a background color of white (according to .systemBackground, not .white), remains black; if dark mode is enabled, the background becomes black and the text becomes white UNLESS some color styling was added to it.

If you're using Cocoapods or Carthage, make sure you actually install it before running with pod install or whatever Carthage does. Again, with Cocoapods, access the .xcworkspace, not .xcodeproj

DrashtiJaviya-Openxcell commented 4 years ago

Hello @YoomamaFTW

Thanks for reply. But using above link code toolbar is not shown and same issue face in above link sample app code also.Could you please share your code with display with toolbar options.

DrashtiJaviya-Openxcell commented 4 years ago

Hello @YoomamaFTW and @az-oolloow Please find below link. I have created a demo of link shared by you but it doesn't work for me. Can you please guide? https://github.com/DrashtiJaviya-Openxcell/RichEditorDemo

YoomamaFTW commented 4 years ago

Hi @DrashtiJaviya-Openxcell Sorry for the delay!

Taking a look at yours, you didn't copy the Sample one correctly. Your ViewController's viewDidLoad() should look like this:

    override func viewDidLoad() {
        super.viewDidLoad()

        editorView.delegate = self
        editorView.inputAccessoryView = toolbar
        editorView.placeholder = "Edit here"

        toolbar.delegate = self
        toolbar.editor = editorView
        editorView.html = "<b>Jesus is God.</b> He saves by grace through faith alone. Soli Deo gloria! <a href='https://perfectGod.com'>perfectGod.com</a>"
    }

The KeyboardManager is an NSObject that has already been defined as "lazy var toolbar".

DrashtiJaviya-Openxcell commented 4 years ago

Hello @YoomamaFTW I had already tried this, but it didn't work. The below screenshot is the expected behaviour. Screenshot The below screenshot is the behaviour of demo Simulator Screen Shot - iPhone X - 2019-10-18 at 10 47 16 Can you please guide me in this? Thanks in advance for your time.

YoomamaFTW commented 4 years ago

Interesting. The one thing I do notice is that the Sample has some header and implementation files (.h and .m). Did you try copying those over? I've never used Storyboards, so I added the editor programmatically. If you'd like, I can send that over, but...

Which simulator are you using? I tried it on a real iPhone 6s and the iPhone 11 simulator working perfectly fine. I'd take note that most users are already on iOS 12 (93% as of July 2019 I believe is what the Apple Docs say).
Your code should look like this:

//
//  ViewController.swift
//  RichEditorViewSample
//
//  Created by Caesar Wirth on 4/5/15.
//  Copyright (c) 2015 Caesar Wirth. All rights reserved.
//
import UIKit
import RichEditorView

class ViewController: UIViewController {

    @IBOutlet var editorView: RichEditorView!
    @IBOutlet var htmlTextView: UITextView!

    lazy var toolbar: RichEditorToolbar = {
        let toolbar = RichEditorToolbar(frame: CGRect(x: 0, y: 0, width: self.view.bounds.width, height: 44))
        toolbar.options = RichEditorDefaultOption.all
        return toolbar
    }()

    override func viewDidLoad() {
        super.viewDidLoad()

        editorView.delegate = self
        editorView.inputAccessoryView = toolbar
        editorView.placeholder = "Type some text..."

        toolbar.delegate = self
        toolbar.editor = editorView

        // We will create a custom action that clears all the input text when it is pressed
        let item = RichEditorOptionItem(image: nil, title: "Clear") { toolbar in
            toolbar.editor?.html = ""
        }

        var options = toolbar.options
        options.append(item)
        toolbar.options = options
    }

}

extension ViewController: RichEditorDelegate {

    func richEditor(_ editor: RichEditorView, contentDidChange content: String) {
        if content.isEmpty {
            htmlTextView.text = "HTML Preview"
        } else {
            htmlTextView.text = content
        }
    }

}

extension ViewController: RichEditorToolbarDelegate {

    fileprivate func randomColor() -> UIColor {
        let colors: [UIColor] = [
            .red,
            .orange,
            .yellow,
            .green,
            .blue,
            .purple
        ]

        let color = colors[Int(arc4random_uniform(UInt32(colors.count)))]
        return color
    }

    func richEditorToolbarChangeTextColor(_ toolbar: RichEditorToolbar) {
        let color = randomColor()
        toolbar.editor?.setTextColor(color)
    }

    func richEditorToolbarChangeBackgroundColor(_ toolbar: RichEditorToolbar) {
        let color = randomColor()
        toolbar.editor?.setTextBackgroundColor(color)
    }

    func richEditorToolbarInsertImage(_ toolbar: RichEditorToolbar) {
        toolbar.editor?.insertImage("https://gravatar.com/avatar/696cf5da599733261059de06c4d1fe22", alt: "Gravatar")
    }

    func richEditorToolbarInsertLink(_ toolbar: RichEditorToolbar) {
        // Can only add links to selected text, so make sure there is a range selection first
        if toolbar.editor?.hasRangeSelection == true {
            toolbar.editor?.insertLink("http://github.com/cjwirth/RichEditorView", title: "Github Link")
        }
    }
}

I believe the reason you're not seeing the toolbar is because of the missing .h and .m files. You can find them here: https://github.com/cjwirth/RichEditorView/tree/master/RichEditorViewSample/RichEditorViewSample