Permalink
Browse files

added switch and two buttons

  • Loading branch information...
1 parent a441ed5 commit dc7ede5c862326e024eac5e53422c546e071c743 Mario Capellari committed Apr 24, 2011
Showing with 432 additions and 63 deletions.
  1. +13 −5 Classes/Control_FunViewController.h
  2. +47 −0 Classes/Control_FunViewController.m
  3. BIN Comic Book Guy.png
  4. +317 −4 Control_FunViewController.xib
  5. BIN build/Control Fun.build/Control Fun.pbxindex/cdecls.pbxbtree
  6. BIN build/Control Fun.build/Control Fun.pbxindex/decls.pbxbtree
  7. BIN build/Control Fun.build/Control Fun.pbxindex/files.pbxbtree
  8. BIN build/Control Fun.build/Control Fun.pbxindex/imports.pbxbtree
  9. BIN build/Control Fun.build/Control Fun.pbxindex/pbxindex.header
  10. BIN build/Control Fun.build/Control Fun.pbxindex/refs.pbxbtree
  11. BIN build/Control Fun.build/Control Fun.pbxindex/strings.pbxstrings/control
  12. BIN build/Control Fun.build/Control Fun.pbxindex/strings.pbxstrings/strings
  13. BIN build/Control Fun.build/Control Fun.pbxindex/subclasses.pbxbtree
  14. BIN build/Control Fun.build/Control Fun.pbxindex/symbols0.pbxsymbols
  15. +7 −7 build/Control Fun.build/Debug-iphonesimulator/Control Fun.build/Control Fun.dep
  16. BIN ...ol Fun.build/Debug-iphonesimulator/Control Fun.build/Objects-normal/i386/Control_FunAppDelegate.o
  17. BIN ...Fun.build/Debug-iphonesimulator/Control Fun.build/Objects-normal/i386/Control_FunViewController.o
  18. +48 −47 build/Control Fun.build/Debug-iphonesimulator/Control Fun.build/build-state.dat
  19. BIN build/Debug-iphonesimulator/Control Fun.app.dSYM/Contents/Resources/DWARF/Control Fun
  20. BIN build/Debug-iphonesimulator/Control Fun.app/Comic Book Guy.png
  21. BIN build/Debug-iphonesimulator/Control Fun.app/Control Fun
  22. BIN build/Debug-iphonesimulator/Control Fun.app/Control_FunViewController.nib
@@ -11,17 +11,25 @@
@interface Control_FunViewController : UIViewController {
UITextField *nameField;
UITextField *numberField;
+ UILabel *sliderLabel;
+ UISwitch *leftSwitch;
+ UISwitch *rightSwitch;
+ UIButton *doSomethingButton;
}
// adding outlets for nib
@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 *doSomethingButton;
-// action for when the text editing is done so we can remove the focus to
-// get rid of the keyboard
-- (IBAction)textFieldDoneEditing:(id)sender;
+- (IBAction)textFieldDoneEditing:(id)sender; // action for when the text editing is done remove keyboard
+- (IBAction)backgroundTap:(id)sender; // action when user taps bg
+- (IBAction)sliderChanged:(id)sender; // action when the slider is being changed
+- (IBAction)switchChanged:(id)sender; // action when the switch is being changed
+- (IBAction)buttonPressed; // action when the button is pressed
-// action when user taps bg
-- (IBAction)backgroundTap:(id)sender;
@end
@@ -12,6 +12,49 @@ @implementation Control_FunViewController
@synthesize nameField;
@synthesize numberField;
+@synthesize sliderLabel;
+@synthesize leftSwitch;
+@synthesize rightSwitch;
+@synthesize doSomethingButton;
+
+const kSwitchesSegmentIndex;
+
+// when toggling controls like the switches
+- (IBAction)toggleControls:(id)sender {
+ if ([sender selectedSegmentIndex] == kSwitchesSegmentIndex)
+ {
+ leftSwitch.hidden = NO;
+ rightSwitch.hidden = NO;
+ doSomethingButton.hidden = YES;
+ } else {
+ leftSwitch.hidden = YES;
+ rightSwitch.hidden = YES;
+ doSomethingButton.hidden = NO;
+ }
+}
+
+// switch changed
+- (IBAction)switchChanged:(id)sender {
+ UISwitch *whichSwitch = (UISwitch *)sender; // sender represents the switch that was pressed
+ BOOL setting = whichSwitch.isOn;
+ [leftSwitch setOn:setting animated:YES];
+ [rightSwitch setOn:setting animated:YES];
+}
+
+// button press
+- (IBAction)buttonPressed {
+ // TODO: implement action sheet and alert
+}
+
+
+// what happens when slider moves
+- (IBAction)sliderChanged:(id)sender {
+ UISlider *slider = (UISlider *)sender;
+ int progressAsInt = (int)(slider.value + 0.5f);
+ NSString *newText = [[NSString alloc] initWithFormat:@"%d", progressAsInt];
+ sliderLabel.text = newText;
+ [newText release];
+}
// this is being called when user taps the bg
// simply resign both test fields
@@ -41,6 +84,10 @@ - (void)viewDidUnload {
- (void)dealloc {
[nameField release];
[numberField release];
+ [sliderLabel release];
+ [leftSwitch release];
+ [rightSwitch release];
+ [doSomethingButton release];
[super dealloc];
}
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.

0 comments on commit dc7ede5

Please sign in to comment.