We start with add our UISegmentedControl programmatically to our view:
1 2 3 4 5 6 7 |
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"All", @"Present", @"Missing", nil]]; segmentedControl.frame = CGRectMake(35, 200, 250, 50); segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar; segmentedControl.selectedSegmentIndex = 0; segmentedControl.tintColor = [UIColor blackColor]; [segmentedControl addTarget:self action:@selector(valueChanged:) forControlEvents: UIControlEventValueChanged]; [self.view addSubview:segmentedControl]; |
Then having added the segment, with the method valueChanged: inserted into addTarget, we can detect the change of state buttons, we can use this method:
1 2 3 4 5 6 7 8 9 10 |
- (void)valueChanged:(UISegmentedControl *)segment { if(segment.selectedSegmentIndex == 0) { //action for the first button (All) }else if(segment.selectedSegmentIndex == 1){ //action for the second button (Present) }else if(segment.selectedSegmentIndex == 2){ //action for the third button (Missing) } } |
Someone essentially lend a hand to make seriously articles I would state. This is the first time I frequented your website page and thus far? I surprised with the analysis you made to create this particular submit amazing. Excellent process!
Thanks! ;)
Wonderful items from you, man. I’ve keep in mind your stuff previous to and you are simply extremely excellent. I really like what you have acquired here, certainly like what you’re stating and the way through which you say it. You’re making it enjoyable and you still take care of to stay it sensible. I can not wait to learn far more from you. This is actually a great web site.
Can you message me with any pointers on how you made your website look this cool, I would appreciate it!
Just to let you know your site appears a little bit unusual in Firefox on my laptop using Linux .
Awesome post ! Cheers for, visiting my blog page dude! Ill email you soon. I didnt realise that.
This is a wonderful weblog, would you be interested in going through an interview about just how you produced it? If so e-mail me and my friends!
How come you do not have your site viewable in mobile format? cant view anything in my iPhone.
Im workin for create it
Fun post, I actually had a good time reading it, keep doing all the good efforts.
I like this web blog very much, Its a very nice post to read and get info .
Adoring the contribution.. bless you Loving the piece of writing.. best wishes So happy to have located this submit.. Terrific ideas you possess here..
Very interesting information!Perfect just what I was searching for!
Isn’t it fantastic any time you get an excellent publish? So content to get identified this post.. Is not it great once you discover a very good article? Is not it excellent if you acquire a fantastic article?
Thank you for this blog, it was just what I was looking for. There is so much information here, so I thank you so much for enlightening my mind.
Have you ever looked at this on iOS 3.x? It doesn’t work syanig;Program received signal: “EXC_BAD_ACCESS”.warning: check_safe_call: could not restore current framewarning: check_safe_call: could not restore current framewarning: Unable to restore previously selected frame.warning: check_safe_call: could not restore current framewarning: Unable to restore previously selected frame.warning: Unable to restore previously selected frame.warning: Unable to restore previously selected frame.Any ideas or are you doing something thats 4.x specific?Love the site btw, some awesome stuff in here kudos!
It looks great, it is worth collecting thank you for sharing.