There is a question: Is it possible to create iOS application . without using Storyboard?. Answer is Yes, it is possible. For implementing this we must create our custom UIWindow and set root controller for it. In code below I show how to do this.
AppDelegate class and didFinishLaunchingWithOptions method
In AppDelegate class method didFinishLaunchingWithOptions we create UIWindow and set root controller for it.
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
self.window = UIWindow(frame: UIScreen.main.bounds)
self.window?.makeKeyAndVisible()
let viewController = ViewController()
let navigationController = UINavigationController(rootViewController: viewController)
self.window?.rootViewController = navigationController
return true
}
}
ViewController
Our ViewController. We set title and add button to center of it using constraints.
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.title = "No Storyboard"
self.view.backgroundColor = UIColor.white
let button = UIButton(type: .system)
button.setTitle("Success", for: .normal)
self.view.addSubview(button)
button.translatesAutoresizingMaskIntoConstraints = false
button.centerXAnchor.constraint(equalTo: self.view.centerXAnchor).isActive = true
button.centerYAnchor.constraint(equalTo: self.view.centerYAnchor).isActive = true
button.widthAnchor.constraint(equalToConstant: 200).isActive = true
button.heightAnchor.constraint(equalToConstant: 50).isActive = true
}
}
Result
One of the key features said to be coming to
ReplyDeletethe HomePod is the ability to make or receive phone calls
Read More At iOS Online Training Bangalore
Thank you very much for drawing my notice to this. Your blog is jam-packed with useful facts. Until I read that, I would have no idea. I'll come back for more fantastic material. Best wishes, and good luck.
ReplyDelete-Custom Web Design
This is an excellent article! Thank you a lot. I'm in desperate need of these suggestions. The in-depth explanation is quite beneficial. It was incredibly encouraging to see how you write. Best Custom Websites
ReplyDeleteThis is a great article! Thank you very much. I really need these suggestions. An in-depth explanation is of great benefit. Incredibly inspiring to see how you write. Custom Website
ReplyDeleteThanks for sharing such a great information.It really helpful to me.I always search to read the quality content and finally i found this in you post. keep it up! On Demand Developers
ReplyDelete