Tutorial details

UISwitch | App Code for Sale | Preview

UISwitch | iOS Tutorial

How to use the UISwitch

Overview PAGE TOP

Reference: http://www.geekylemon.com/WEBPROTECT-xcodetutorialuiswitch.htm

In this tutorial i will be showing you how to use the UISwitch


  • 1 UISwitch
  • 2 Round rect button
  • 1 UILabel

using uiswitches in your projects to control content on the screen such as setting text in labels and hiding and revealing buttons is a great way to controll content in your app

ViewController.h PAGE TOP

@interface ViewController :UIViewController {
IBOutlet UISwitch *switchButton;
IBOutlet UILabel *label;
IBOutlet UIButton *button1;
IBOutlet UIButton *button2;

ViewController.m PAGE TOP

@implementation ViewController
-(IBAction)theSwitch {
if (switchButton.on) {
label.text = @"Switch is on button 1 is shown";
button1.hidden = NO;
button2.hidden = YES;
else {
label.text = @"Switch is off button 2 is shown";
button1.hidden = YES;
button2.hidden = NO;

When linking the action to the switch make sure you select value changed

Reference PAGE TOP


0 Comments Leave a comment

Please login in order to leave a comment.

Newest first

to your Chupamobile Account.

The Easiest way to Launch your next App or Game.

Join Chupamobile and get instant access to thousands of ready made App and Game Templates.

Creating an account means you’re okay with Chupamobile’s Terms of Service and Privacy Policy.