//
// ViewController.h
// Control Fun
//
// Created by qixing huang on 12-1-12.
// Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
{
UITextField *nameField;
UITextField *numberField;
UILabel *sliderLabel;
UISwitch *leftSwitch;
UISwitch *rightSwitch;
UIButton *doSomething;
}
@property (nonatomic, retain) IBOutlet UITextField *nameField;
@property (nonatomic, retain) IBOutlet UITextField *numberField;
@property (nonatomic, retain) IBOutlet UILabel *sliderLabel;
@property (nonatomic, retain) IBOutlet UISwitch *leftSwitch;
@property (nonatomic, retain) IBOutlet UISwitch *rightSwitch;
@property (nonatomic, retain) IBOutlet UIButton *doSomething;
- (IBAction)textFieldDoneEditing:(id)sender;
- (IBAction)backgroundTap:(id)sender;
- (IBAction)sliderChange:(id)sender;
- (IBAction)toggleControls:(id)sender;
- (IBAction)switchChanged:(id)sender;
- (IBAction)buttonPressed;
@end
#import "ViewController.h"
@implementation ViewController
@synthesize nameField;
@synthesize numberField;
@synthesize sliderLabel;
@synthesize leftSwitch;
@synthesize rightSwitch;
@synthesize doSomething;
- (IBAction)toggleControls:(id)sender{
}
- (IBAction)sliderChange:(id)sender{
UISlider *slider = (UISlider *)sender;
int progressAsInt = (int) (slider.value +0.5f);
NSString *newText = [[NSString alloc] initWithFormat:@"%d",progressAsInt ];
sliderLabel.text = newText;
}
- (IBAction)backgroundTap:(id)sender{
[nameField resignFirstResponder];
[numberField resignFirstResponder];
}
- (IBAction)textFieldDoneEditing:(id)sender{
[sender resignFirstResponder];
}