yego.me
💡 Stop wasting time. Read Youtube instead of watch. Download Chrome Extension

Objective-C iPhone Programming Lesson 6 part 2 - Sliders and Progress Indicators


3m read
·Nov 3, 2024

Processing might take a few minutes. Refresh later.

Hey guys, this is Matt Kizuna. One with our 6th iPhone programming tutorial. In this tutorial, I'm going to be showing you how to use sliders and progress indicators.

So first of all, we're going to go to Xcode, your file, new project, and let's create a view-based application. I applied its sliders and progress, and it doesn't really matter.

Alright, so I'm going to start. Instead of setting up our interface first, I'm going to write all the code this time, then set up the interface once. So I'm going to say in our .h file, SliderProgressViewController.h, you're going to say IBOutlet like UI Slider slider1. We're going to say IBOutlet UI ProgressView progress1.

Alright, now we're going to make an IBAction called sliderSlid. I will just get that set up, and let's hook up this code in here. And we're going to see progress1 set progress. We're going to send it to slider1, and here we'll say value.

Alright, in the implementation of its value there, I'll check that. Alright, now we'll go into the interface builder file and will drag on a slider and the progress. If you notice the difference between a progress view and a progress indicator, this is a progress indicator, the spinny thing. Progress views, this loading bar, so we're going to have one of these.

I'm going to make it slightly wider, I think, and you'll see why in a minute, and I'll hook these up. This will be slider1, and this will be progress1. At this point, if you don't know how to hook these up, you should watch our previous tutorials.

Now I'll center these into the center of the screen. So now, oh, and I forgot to hook up our action. Sorry guys, let's go back here. By the way, you're going to make sure Continuous is checked. We're gonna click from here, hook up our action, and this doesn't... it won't do much, but we'll see when it comes up.

Then we can go ahead and slide. Now this is great because, you know, it looks pretty fluid. It's pretty awesome! I think I did this in a Mac programming tutorial as well.

Anyway, so that's basically the basics that demonstrate, like killing two birds with one stone. It demonstrates, like, a slider and demonstrates this progress indicator. So if we look in the code once more, you're seeing progress set progress here. You're going to want to give it a float, which is a floating-point number that's like an int except it's float instead.

To do that, we get the value of slider1, which returns a float. It makes sense. We can make this 0.2 or 1, whatever, and it'll just set the progress to 0.1, whatever we slide this. We can say slider1 set, and this is sort of useless because yes, 0.4. So this will be kind of weird, as you'll see, because it's going to not slide.

So we're going to be able to slide this slider, and it's not going to change. The thing under, it's going to change. It's quite weird, it is. So yeah, so that's like a demonstration of how to do stuff.

Now you might be wondering, well, how do I make a progress bar, you know, to measure the loading progress of a web page or whatever? Well, that's different. All you do is you set the progress of it to however much percent that process is complete, and you have to figure that out yourself. So maybe I'll go into that later when I start doing network stuff and stuff with servers.

So now we're going to make a little sort of... I don't know if I can call it a game, but I'll say value, and I'll make another increase value. I'll just make this say, you know, I don't even need this.

What we're going to do now is we're going to make a button that moves up both of these values. So it's just making a button that says Increase. Let's just drag it here, and now in the code for this, we're going to be increasing the value of progress1.

So we're going to say progress1 set progress progress1 progress plus 1. And I know there are a lot of ones, and progress is in that—that's pretty funny. And we're going to say slider1 set value slider1 value plus 1.

And yeah, so now when we click this button, both the slider and the progress bar are going to increase. So let's drag...

More Articles

View All
How to be a Pirate Captain! 🌈 ☠️ 🌈
(Captain) Hello! So you want to be a pirate, m’lad? Well let me tell ye… being a pirate, be all about ‘Branding’. Yar, it’s a business. But branding be bringing in the booty. And if ye be shipping with our jolly crew, ye need love this Jolly Roger. (Recr…
Quirkiest Investments that Have DOUBLED IN VALUE | Kevin O'Leary
Sharks! All right, we’re here to pick up the Maki-E MontBlanc. I’m among one of 88 in the world. This is number 13, and it’s on its way into Mr. Wonderful’s pen collection. At the prototype, I shot that with Shark Tank. Here it is for the first time. Wow…
Teaching ELA with Khanmigo
Hi, I’m Michelle, a professional learning specialist here at Khan Academy and a former classroom teacher, just like you. Today, I have the pleasure of introducing you to Kigo, your AI-driven companion who’s revolutionizing teaching for a more engaging and…
How to be Limitless in Real Life - 5 Ways to Increase Brain Power
Ever since I saw the movie “Limitless” starring Bradley Cooper, I’ve been obsessed with the idea of using your brain to its fullest potential. More specifically, the ability to remember everything you have ever learned and be able to communicate that info…
Why Stupidity is Power | Priceless Benefits of Being Stupid
People generally fear being perceived as stupid. Often, stupid people are looked down upon and laughed at. Society perceives stupid people as useless, as a burden rather than an asset. Hence, most of us try to prevent ourselves from appearing stupid in fr…
What Makes You a Degenerate? | Stoic Philosophy
Here is your great soul – the man who has given himself over to Fate; on the other hand, that man is a weakling and a degenerate who struggles and maligns the order of the universe and would rather reform the gods than reform himself. Imagine a society w…