Skip to content

Commit

Permalink
Page 89
Browse files Browse the repository at this point in the history
  • Loading branch information
Tammer Saleh committed May 31, 2009
1 parent c74bb8a commit f0a1448
Show file tree
Hide file tree
Showing 8 changed files with 559 additions and 101 deletions.
15 changes: 13 additions & 2 deletions Control Fun/Classes/Control_FunViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,32 @@
//

#import <UIKit/UIKit.h>
#define kShowSegmentIndex 0


@interface Control_FunViewController : UIViewController {
@interface Control_FunViewController : UIViewController <UIActionSheetDelegate> {
IBOutlet UITextField *nameField;
IBOutlet UITextField *numberField;
IBOutlet UILabel *sliderLabel;
IBOutlet UISwitch *leftSwitch;
IBOutlet UISwitch *rightSwitch;
IBOutlet UIView *switchView;
IBOutlet UIButton *doSomethingButton;
}

@property (nonatomic, retain) UITextField *nameField;
@property (nonatomic, retain) UITextField *numberField;
@property (nonatomic, retain) UILabel *sliderLabel;
@property (nonatomic, retain) UISwitch *leftSwitch;
@property (nonatomic, retain) UISwitch *rightSwitch;
@property (nonatomic, retain) UIView *switchView;
@property (nonatomic, retain) UIButton *doSomethingButton;

- (IBAction)textFieldDoneEditing:(id)sender;
- (IBAction)backgroundClick:(id)sender;
- (IBAction)sliderChanged:(id)sender;
- (IBAction)switchChanged:(id)sender;
- (IBAction)toggleShowHide:(id)sender;
- (IBAction)doSomething:(id)sender;

@end

59 changes: 59 additions & 0 deletions Control Fun/Classes/Control_FunViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,65 @@ @implementation Control_FunViewController
@synthesize nameField;
@synthesize numberField;
@synthesize sliderLabel;
@synthesize leftSwitch;
@synthesize rightSwitch;
@synthesize switchView;
@synthesize doSomethingButton;

- (void)viewDidLoad {
UIImage *buttonImageNormal = [UIImage imageNamed:@"whitebutton.png"];
UIImage *stretchableButtonImageNormal = [buttonImageNormal stretchableImageWithLeftCapWidth:12 topCapHeight:0];
[doSomethingButton setBackgroundImage:stretchableButtonImageNormal forState:UIControlStateNormal];

UIImage *buttonImagePressed = [UIImage imageNamed:@"blackbutton.png"];
UIImage *stretchableButtonImagePressed = [buttonImagePressed stretchableImageWithLeftCapWidth:12 topCapHeight:0];
[doSomethingButton setBackgroundImage:stretchableButtonImagePressed forState:UIControlStateHighlighted];
}

- (IBAction)doSomething:(id)sender {
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Are you sure?"
delegate:self
cancelButtonTitle:@"No way!"
destructiveButtonTitle:@"Yes, I'm sure."
otherButtonTitles:nil];
[actionSheet showInView:self.view];
[actionSheet release];
}

- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (!(buttonIndex == [actionSheet cancelButtonIndex])) {
NSString *msg = nil;

if (nameField.text.length > 0)
msg = [[NSString alloc] initWithFormat:@"You can breath easy, %@, everything went OK.", nameField.text];
else
msg = @"You can breath easy, everything went OK.";

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Something was done"
message:msg
delegate:nil
cancelButtonTitle:@"Phew!"
otherButtonTitles:nil];
[alert show];
[alert release];
[msg release];
}
}

- (IBAction)switchChanged:(id)sender {
UISwitch *whichSwitch = (UISwitch *)sender;
BOOL setting = whichSwitch.isOn;
[leftSwitch setOn:setting animated:YES];
[rightSwitch setOn:setting animated:YES];
}

- (IBAction)toggleShowHide:(id)sender {
UISegmentedControl *segmentedControl = (UISegmentedControl *)sender;
NSInteger segment = segmentedControl.selectedSegmentIndex;

if (segment == kShowSegmentIndex) [switchView setHidden:NO];
else [switchView setHidden:YES];
}

- (IBAction)sliderChanged:(id)sender {
UISlider *slider = (UISlider *)sender;
Expand Down
8 changes: 8 additions & 0 deletions Control Fun/Control Fun.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
2899E5220DE3E06400AC0155 /* Control_FunViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2899E5210DE3E06400AC0155 /* Control_FunViewController.xib */; };
28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28AD733E0D9D9553002E5188 /* MainWindow.xib */; };
28D7ACF80DDB3853001CB0EB /* Control_FunViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28D7ACF70DDB3853001CB0EB /* Control_FunViewController.m */; };
9AE07C2A0FD2F18000FC31A6 /* blueButton.png in Resources */ = {isa = PBXBuildFile; fileRef = 9AE07C280FD2F18000FC31A6 /* blueButton.png */; };
9AE07C2B0FD2F18000FC31A6 /* whiteButton.png in Resources */ = {isa = PBXBuildFile; fileRef = 9AE07C290FD2F18000FC31A6 /* whiteButton.png */; };
9AF219A50FD0C6F500CD81A0 /* apress_logo.png in Resources */ = {isa = PBXBuildFile; fileRef = 9AF219A40FD0C6F500CD81A0 /* apress_logo.png */; };
/* End PBXBuildFile section */

Expand All @@ -32,6 +34,8 @@
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
32CA4F630368D1EE00C91783 /* Control_Fun_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Control_Fun_Prefix.pch; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
9AE07C280FD2F18000FC31A6 /* blueButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = blueButton.png; sourceTree = "<group>"; };
9AE07C290FD2F18000FC31A6 /* whiteButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = whiteButton.png; sourceTree = "<group>"; };
9AF219A40FD0C6F500CD81A0 /* apress_logo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = apress_logo.png; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -92,6 +96,8 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
9AE07C280FD2F18000FC31A6 /* blueButton.png */,
9AE07C290FD2F18000FC31A6 /* whiteButton.png */,
9AF219A40FD0C6F500CD81A0 /* apress_logo.png */,
2899E5210DE3E06400AC0155 /* Control_FunViewController.xib */,
28AD733E0D9D9553002E5188 /* MainWindow.xib */,
Expand Down Expand Up @@ -155,6 +161,8 @@
28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */,
2899E5220DE3E06400AC0155 /* Control_FunViewController.xib in Resources */,
9AF219A50FD0C6F500CD81A0 /* apress_logo.png in Resources */,
9AE07C2A0FD2F18000FC31A6 /* blueButton.png in Resources */,
9AE07C2B0FD2F18000FC31A6 /* whiteButton.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Loading

0 comments on commit f0a1448

Please sign in to comment.