Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Value of type 'UIView' has no member 'present' - how to invoke 'present'? [duplicate]

i have a uiview file that i embedded into my tableview header

(class TopHeader: UIView, UICollectionViewDelegate, UICollectionViewDataSource)

If I use present(_:animated:completion:) i am getting: Value of type TopHeader has no member 'present' ( self.present(MyOtherViewController(doModes: [.photo]), animated: true, completion: nil))

How can I use the present method from there? Can I call a function that is in my uiviewcontroller from this uiview file?

like image 253
Tel4tel Avatar asked Oct 16 '25 13:10

Tel4tel


1 Answers

You can't call present(_:animated:completion) because it is a method of UIViewController, not UIView.

You shouldn't be presenting view controllers from views directly. If you need this behavior, it would be better to use a UIViewController instead of a UIView since the view controller will contain a view within it anyway.

like image 52
Paolo Avatar answered Oct 19 '25 15:10

Paolo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!