How to open a new view with a button programatically (UIKit, Swift 2023)
ฝัง
- เผยแพร่เมื่อ 12 ม.ค. 2025
- In this video we will learn how to programmatically open a new UIViewController with a UIButton. We will learn how to do it modally (pop up) and also push it into a navigation controller stack.
If this video helped out and you want to see more iOS/Swift videos,
please consider subscribing.
If you liked the video, leave a like or comment!
If coding is too hard, you can hire me:
www.fiverr.com...
Gigantic thanks! I wasn't understanding using Tab Bar and Navigation Bar together before see this video. And now I'm cured! 🤩
Your videos is very helpful. Please keep it up!
Really need video for networking in Swift
Maybe like video series how to send a request, get data, parse it and put it into a tableview/collectionView
Thank you!
so simple you made it!
very helpful
ty, bro
how to learn how to solve tasks ? and how to develop thinking into programming on swift
This still work?
thread 1:"unable to activate constraint with anchor "
Send me the code in your setupUI() function pls!
@@Codebrah private func setupUI() {
self.view.backgroundColor = .systemGreen
self.button.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
button.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
button.centerYAnchor.constraint(equalTo: self.view.centerYAnchor),
button.widthAnchor.constraint(equalToConstant: 200),
button.heightAnchor.constraint(equalToConstant: 44)
])}
@@CodebrahI also want to say I really like your videos (french developper don't explain as well as u )
@@anthonybarbedet6915 Okay thats what I thought was going on!
Before you put: self.button.translatesAutoresizingMaskIntoConstraints = false
You need to put: self.view.addSubview(button)
So in total it will look like:
private func setupUI() {
self.view.backgroundColor = .systemGreen
self.view.addSubview(button)
self.button.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
button.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
button.centerYAnchor.constraint(equalTo: self.view.centerYAnchor),
button.widthAnchor.constraint(equalToConstant: 200),
button.heightAnchor.constraint(equalToConstant: 44)
])}
Goodluck!
@@anthonybarbedet6915 Appreciate that my friend!