我上的是速成班

@objc public class LoadingOverlay : NSObject{

            @objc var overlayView : UIView!
            @objc var activityIndicator : UIActivityIndicatorView!

            @objc class var shared: LoadingOverlay {
                struct Static {
                    static let instance: LoadingOverlay = LoadingOverlay()
                }
                return Static.instance
            }

            @objc override init(){
                self.overlayView = UIView()
                self.activityIndicator = UIActivityIndicatorView()

                overlayView.frame = CGRect(origin: CGPoint(x:0, y:0), size: CGSize(width:80, height:80))
                overlayView.backgroundColor = UIColor(white: 0, alpha: 0.7)
                overlayView.clipsToBounds = true
                overlayView.layer.cornerRadius = 10
                overlayView.layer.zPosition = 1

                activityIndicator.frame = CGRect(origin: CGPoint(x:0, y:0), size: CGSize(width:40, height:40))
                activityIndicator.center = CGPoint(x:overlayView.bounds.width / 2, y:overlayView.bounds.height / 2)
                activityIndicator.activityIndicatorViewStyle = .whiteLarge
                overlayView.addSubview(activityIndicator)
            }

            @objc public func showOverlay(view: UIView) {
                overlayView.center = view.center
                view.addSubview(overlayView)
                activityIndicator.startAnimating()
            }

            @objc public func hideOverlayView() {

                DispatchQueue.main.async(execute: {
                    self.activityIndicator.stopAnimating()
                    self.overlayView.removeFromSuperview()
                })
            }
        }

我用一个目标c方法调用这个类
LoadingOverlay *sharedManager = [LoadingOverlay shared];
        [sharedManager showOverlay:(self.view)];

我发现了这个错误
No visible @interface for 'LoadingOverlay' declares the selector 'showOverlay:'

我该怎么解决?

最佳答案

目标c附加(labelOfParameter),因此将其转换为

 LoadingOverlay *sharedManager = [LoadingOverlay shared];
 [sharedManager showOverlayWithView:self.view];

关于swift - 'LoadingOverlay'的可见@interface没有声明选择器'showOverlay:',我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51450385/

10-12 00:27