I have been trying to show UIViewController
on the whole screen while using the present modal?
here is the output image
[![enter image description here][1]][1]
I have xib viewController where I am trying to send value to another viewController using the present method but it does not fit fullscreen.
Here is the code :
let vc = TabBarViewController()
vc.processDefID = keyVal
vc.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
vc.modalPresentationStyle = .overFullScreen //or .overFullScreen for transparency
self.present(vc, animated: true, completion: nil)
ANother mehtod tried:
var clientView: UIViewcontroller
let V = TabBarViewController()
self.clientView?.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
self.clientView?.addChild(V)
self.clientView?.view.addSubview(V.view)
V.processDefID = keyVal
V.view.frame = (self.clientView?.view.bounds)!
V.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
V.modalPresentationStyle = .fullScreen
self.present(V, animated: true, completion: nil)
Normally you can show/present your view in two way.
Create UIViewController
object and present it in the way you are doing
func presentView() {
let vc = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ScannerViewController")
vc.view.backgroundColor = .red
vc.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
vc.modalPresentationStyle = .fullScreen
self.present(vc, animated: true, completion: nil)
}
In the case of using UIViewController
with XIB
file, it will just change the ViewController initialisation part and nothing else, just like
let vc = ScannerViewController(nibName: "ScannerView", bundle: nil)
Create UIViewController
object and insert it in the following way, you can also assign the custom frame to it's UIView
object.
func presentView() {
let vc = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ScannerViewController")
vc.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height/2)
vc.view.backgroundColor = .red
self.addChild(vc)
self.view.addSubview(vc.view)
}