Custom Alerts | Swift 4, Xcode 10

  Рет қаралды 20,342

Kilo Loco

Kilo Loco

Күн бұрын

Today we cover how to create your very own custom alerts. UIAlertController is great when working with simple alerts that maintain a consistent look through iOS. However, there are times when you need your alert to do custom functionality or have a certain look and feel.
By the end of this tutorial, you will know how to implement your customized alert in a dynamic fashion using storyboards.
** Show Notes and Links **
Need Help?
kiloloco.com/m...
Project Files:
kilo-loco.teac...
Kyle Lee on Social Media:
www.kiloloco.com
KZbin- / kiloloco
Twitter- / kilo_loco
Instagram- / kilo_loco
--------GEAR ------
Code Passionately T-Shirt
a.co/d/53OkIu0
Laptop - 2017 MacBook Pro
amzn.to/2tk5yLr
Microphone - PowerDeWise Lavalier Microphone
amzn.to/2In9PCh
DISCLAIMER: This video and description contains affiliate links, which means that if you click on one of the product links, we’ll receive a small commission. This helps support the channel and allows us to continue to make videos like this. Thank you for the support!

Пікірлер: 71
@skerzo1880
@skerzo1880 3 жыл бұрын
Best tutorial I've seen on this kind of thing. Thank you!!!! Also love the production quality
@jameskayihura1675
@jameskayihura1675 4 жыл бұрын
You've just saved my day. Ure not only a teacher but also a good guy.
@nikhilthite2959
@nikhilthite2959 5 жыл бұрын
This was the best tutorial I have seen, very well explained, awesome presentation. Great work!!!
@MarioDelfinoe
@MarioDelfinoe 3 жыл бұрын
This was incredible, the explanation was clear, well presented, an excellent teacher. Congratulations and thanks for sharing.
@shobhaKhuShbhu35
@shobhaKhuShbhu35 3 жыл бұрын
Thank you so much for this video, very easiest way to create custom alert. Nice explanation.
@talalbadreddine3978
@talalbadreddine3978 2 жыл бұрын
Thank you , keep on providing valuable content :)
@RobertHolzapfel
@RobertHolzapfel 5 жыл бұрын
Thanks Kyle Lee -> It is always a pleasure listening to you boy, it is funny on the one hand but also very instructive and informativ. You always make me feel better due to your strong positive attitude and joy you seem to have when coding. Thumbs up! 👍🏻 Have a nice day and thank you very much indeed. 😁
@Kilo_Loco
@Kilo_Loco 5 жыл бұрын
Glad that you can enjoy the content on several levels. Hope I can keep up the quality to keep people like you coming back 😁
@ConvicTPL
@ConvicTPL 5 жыл бұрын
God dammit, its 3:07 AM and instead of sleeping im laying in bed watching Your tutorial how to make sexy ass alerts, that how good Your content is.
@Kilo_Loco
@Kilo_Loco 5 жыл бұрын
Haha! Glad to hear that my content is entertaining enough to keep you awake. Help me deprive more people of sleep by sharing the channel 😉
@Akonkol2
@Akonkol2 5 жыл бұрын
Great job! Your videos are really helping me progress! Straight to the point and relevant.
@Kilo_Loco
@Kilo_Loco 5 жыл бұрын
And hopefully a little entertaining while you’re learning 😉
@Akonkol2
@Akonkol2 5 жыл бұрын
Kilo Loco if we sign up for the monthly thing can we get assistance on slack with questions about other items besides what’s in the videos?
@Kilo_Loco
@Kilo_Loco 5 жыл бұрын
Absolutely! That’s actually the whole point of the Slack community. It makes it easier for me to respond as I check Slack constantly throughout the day and it allows my students to send code snippets as to what they’re doing and what’s wrong in their project.
@Nick6661992
@Nick6661992 3 жыл бұрын
Hey Kyle, really like your approach, and a big fan. What would you think of using Dependency Injection instead of the method in the Alertservice class?
@alirezaaj1957
@alirezaaj1957 5 жыл бұрын
that was an awwwwsome lesson with great content and passionate explanation , thanks kilo
@Kilo_Loco
@Kilo_Loco 5 жыл бұрын
My pleasure 😁
@xTwisteDx
@xTwisteDx 3 жыл бұрын
Fantastic tut. As always
@bigmtnstudio
@bigmtnstudio 5 жыл бұрын
What? 35% for the background transparency? Darn it, Kyle, you told me 40% once when I asked on Twitter! Ha ha ha. Just giving you a hard time. I like how you made the popup expandable on the content. That was super cool. Hey, I had an idea with the AlertService class. My coworker gave us this idea. He started creating the view controller initialization function right in the view controller itself. So maybe instead of the AlertService, that logic would be in the AlertViewController. Something like this: It's static so in other view controllers you would use like this: class AlertViewController: UIViewController { @IBOutlet weak var titleLabel: UILabel! @IBOutlet weak var bodyLabel: UILabel! @IBOutlet weak var actionButton: UIButton! var buttonAction: (() -> Void)? static func create(title: String, body: String, buttonTitle: String, completion: @escaping () -> Void) -> AlertViewController { let storyboard = UIStoryboard(name: "AlertStoryboard", bundle: nil) let alertVC = storyboard.instantiateInitialViewController() as! AlertViewController alertVC.titleLabel.text = title alertVC.bodyLabel.text = body alertVC.actionButton.setTitle(buttonTitle, for: .normal) alertVC.buttonAction = completion return alertVC } // Other functions } It's static so you'd call it something like this from other view controllers: class ViewController: UIViewController { @IBOutlet weak var emojiLabel: UILabel! @IBAction func didTapSubscribe() { let alertVC = AlertViewController.create(title: "Subscribe?", body: "Please subscribe to the channel if you found this helpful", buttonTitle: "Confirm") { [weak self] in self?.emojiLabel.text = "😁" } present(alertVC, animated: true) } } Just wanted to share that. Since our coworker showed us this way, we've been using it ever since because it's just so handy.
@Kilo_Loco
@Kilo_Loco 5 жыл бұрын
Lol, actually what I told you on twitter was exactly right. Only problem is that I forgot what that number was and I was too lazy to go back and find the video. At least now I'll remember that it is 40% In regards to the your method for the Alert View Controller, that is a really good idea, I've actually come up with several ways of making alert controllers dynamic like this. The problem is there's always this huge debate on what's the best and proper way of doing these things and some people argue about static properties, others argue about singletons, but the one thing no1 seems to argue about is dependency injection. At work I actually use a method very similar to your suggestion on one of the projects, except its a distance method in the extension of UIViewController. I just call it like presentAlert(title: String, message: String, execute: @escaping () -> Void) . Alerts are always used in view controllers but this is something that would be frowned upon in some groups. Anyways, I appreciate the suggestion, and I love your content 😁 Also if there's something we can collaborate on, let me know. I think we're the only two iOS content creators with family to support, so I think there might be a lot in common or something that we could come together on with a perspective that some other content creators don't have.
@bigmtnstudio
@bigmtnstudio 5 жыл бұрын
@@Kilo_Loco , oh that's cool too. You said, "...distance method in the extension..."? I'm not sure what you mean. I hear ya on the family, ha ha. If I think of anything I'll definitely let you know. Got my hands full right now. I'm starting to create a new course for this company Pluralsight that's here in Utah. Online tech training company. We'll see how that goes and if it's financially viable.
@viewsfromthenorth2308
@viewsfromthenorth2308 4 жыл бұрын
Thanks! But if 2 or more buttons in alert view controller? how do I add another button in alertservice?
@albertyu7051
@albertyu7051 4 жыл бұрын
"Nice and stretched out" lmao. Thank you for the tutorial
@EulerAlvarenga1
@EulerAlvarenga1 5 жыл бұрын
great job Kilo. I'd like a tutorial on callbacks in Swift plz
@Kilo_Loco
@Kilo_Loco 5 жыл бұрын
Will do trello.com/c/KYvRtwaB
@Aamirkhan-bh5yp
@Aamirkhan-bh5yp 4 жыл бұрын
This is a life saver any idea how to add a UITableview instead of passing a label this would really help a lot pls!
@donathmm3881
@donathmm3881 5 жыл бұрын
Great Video :))). Yes it would be cool if you can make a video about closures
@Kilo_Loco
@Kilo_Loco 5 жыл бұрын
Alright, I got it down as one of the topics to cover trello.com/c/KYvRtwaB
@kareemdasilva
@kareemdasilva 4 жыл бұрын
Good job Kilo
@Kilo_Loco
@Kilo_Loco 4 жыл бұрын
HAHA thanks!
@stutidobhal
@stutidobhal 5 жыл бұрын
This is an awesome tutorial. Love your videos. Would love to have a video on closures.
@Kilo_Loco
@Kilo_Loco 5 жыл бұрын
Glad you liked it. I will definitely add closures to the list of todos trello.com/c/KYvRtwaB
@Bamboogalou
@Bamboogalou 4 жыл бұрын
Man this is straight sauce.
@CuriosMindDIY
@CuriosMindDIY 5 жыл бұрын
Thank you Kilo, great video as always 👏🏼
@Kilo_Loco
@Kilo_Loco 5 жыл бұрын
Thanks! If there’s anyway to make my content better or if there’s a topic you want covered, please let me know.
@CuriosMindDIY
@CuriosMindDIY 5 жыл бұрын
Kilo Loco I have two topics actually lol. The callback method would be great for a start, also a collectionView inside a tableViewCell, how to achieve it’s dataSource and delegate! Ty again!
@Kilo_Loco
@Kilo_Loco 5 жыл бұрын
A good place to start for closures/callbacks would be these two videos kzbin.info/www/bejne/rIS3ZYiEadhkock kzbin.info/www/bejne/j6LLp4mvnqqjf5I I will add collection views inside of tables views to the list of topics to cover trello.com/c/yT5m5a3M
@rodherr9825
@rodherr9825 3 жыл бұрын
Hi man, its fantastic, but a have one question, how can I do the callback when I press cancel button
@ericsmith2405
@ericsmith2405 5 жыл бұрын
Great video Kilo!! Make more!
@Kilo_Loco
@Kilo_Loco 5 жыл бұрын
I plan on keeping them coming. Got big plans for the channel 😁
@kapilchouhan9981
@kapilchouhan9981 4 ай бұрын
If we want to show this popup just before view controller appear, that is on to the splash screen then what we can do here? Please suggest
@Neographic84
@Neographic84 3 жыл бұрын
Hello I wanted to ask you a question .. If the text of the alert is longer than the view that contains it? How can this be solved? can you give a small example?
@eduardofulgencio741
@eduardofulgencio741 4 жыл бұрын
Muy simple y útil para aplicar. Gracias.
@vitorgomes4794
@vitorgomes4794 3 жыл бұрын
First of all, thanks for sharing this nice tutorial with us man :). Second, I would like to ask you something. In case that my alert has some textfields, switches, date pickers, how can I retrieve data from there?
@TheTeamojacky
@TheTeamojacky 5 жыл бұрын
Thank you so much, you're the best !
@aliakkawi4759
@aliakkawi4759 5 жыл бұрын
Thanks for the tutorial, we can also use view controllers with xibs instead of a new storyboard
@Kilo_Loco
@Kilo_Loco 5 жыл бұрын
Yes absolutely you can
@maxi_798
@maxi_798 5 жыл бұрын
Thank you so much. It is really helpful to me. 👍
@musiniganesh
@musiniganesh 5 жыл бұрын
Hi Kilo, nice tutorial. Just i have one query, if i want to create callback for cancel button also, then how can we do and how can we access in alertservices file, Please can you write just one line cod e here. Thanks in advance
@elviss911
@elviss911 5 жыл бұрын
Friend, how to pasa data from custom dialog to main viewcontroller? Can you help me.
@jordiaguilar658
@jordiaguilar658 3 жыл бұрын
Thanks a lot. Great job
@falsanomo
@falsanomo 5 жыл бұрын
At 3:27 you selected a view but referred to it as a container view. That threw me off a bit. But nevertheless this was an awesome and extremely useful tutorial. Thank-you!
@42kenward
@42kenward 3 жыл бұрын
Yeah that threw me too! My view comes up as transparent and I've no idea why! :D
@mackyy26
@mackyy26 4 жыл бұрын
what if the alert action return string how to do it? Thanks pls help
@oonarauhala9960
@oonarauhala9960 4 жыл бұрын
Thanks! Helped a lot :)
@anasilvia4088
@anasilvia4088 5 жыл бұрын
Thank you! very helpful
@TheMakdeniz
@TheMakdeniz 4 жыл бұрын
Brilliant!
@it_jedi_onchill
@it_jedi_onchill 4 жыл бұрын
Thanks so much! You're the best teacher in this fucking world! )
@stotchmania
@stotchmania 2 жыл бұрын
yes. yes. omg yes. thankyou
@guruitcompany
@guruitcompany 5 жыл бұрын
Nice! Thank you very much 👍👍👍
@Kilo_Loco
@Kilo_Loco 5 жыл бұрын
Always a pleasure! If there’s anyway to make my content better or if there’s a topic you want covered, please let me know.
@TheKbs95
@TheKbs95 5 жыл бұрын
can you do video, where we have a minimised controller over a mainViewController, just like. youtube where you can interact with both the view controllers
@Kilo_Loco
@Kilo_Loco 5 жыл бұрын
I will add that to the list of todos
@JohnoOz
@JohnoOz 4 жыл бұрын
Fantastic! Thanks...
@СергейПротоцкий
@СергейПротоцкий 5 жыл бұрын
That was nice!
@Kilo_Loco
@Kilo_Loco 5 жыл бұрын
Thanks! If there’s anyway to make my content better or if there’s a topic you want covered, please let me know.
@ALxD7MY
@ALxD7MY 5 жыл бұрын
thank u bro 🌹
@luisbert8107
@luisbert8107 5 жыл бұрын
Thanks!
@Kilo_Loco
@Kilo_Loco 5 жыл бұрын
You’re welcome 😇 If there’s anyway to make my content better or if there’s a topic you want covered, please let me know.
@MrAmazinG023
@MrAmazinG023 4 жыл бұрын
Nice video. Although, I'd prefer extending UIViewController instead of making AlertService. That would result in just calling showAlert("title", bla bla bla) { }
@anonweareleague5691
@anonweareleague5691 4 жыл бұрын
God damn, its BuTTon, not Buhon..
Use Closures Not Delegates | Swift 5, Xcode 10
14:52
Kilo Loco
Рет қаралды 24 М.
One Time Code Text Field | Swift 5, Xcode 10
32:38
Kilo Loco
Рет қаралды 20 М.
Will A Basketball Boat Hold My Weight?
00:30
MrBeast
Рет қаралды 93 МЛН
Я сделала самое маленькое в мире мороженое!
00:43
Кушать Хочу
Рет қаралды 4,8 МЛН
Wait for the last one 🤣🤣 #shorts #minecraft
00:28
Cosmo Guy
Рет қаралды 7 МЛН
Double Tap To Like | Swift 4, Xcode 10
18:33
Kilo Loco
Рет қаралды 6 М.
Reusable Custom Popups - Part 1 (iOS, Xcode 9, Swift 4)
25:44
Mark Moeykens
Рет қаралды 74 М.
Creating Hyperlinks | Swift 5, Xcode 10
12:18
Kilo Loco
Рет қаралды 13 М.
can this machine earn me money?
17:51
The Swedish Maker
Рет қаралды 25 М.
Expanding Table View Cells! (Swift 4 in Xcode)
13:01
Jared Davidson
Рет қаралды 122 М.
Weak and Unowned Self Closure Memory Leak Fixes
12:21
Lets Build That App
Рет қаралды 56 М.
Opening Other Apps | Swift 4, Xcode 10
15:09
Kilo Loco
Рет қаралды 18 М.
How to create custom alert in iOS || Custom UIAlert for the beginners.
20:15
Will A Basketball Boat Hold My Weight?
00:30
MrBeast
Рет қаралды 93 МЛН