- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
Control_FunViewController.m
上传用户:jjjjag8
上传日期:2017-04-17
资源大小:1443k
文件大小:4k
源码类别:
iPhone
开发平台:
MultiPlatform
- //
- // Control_FunAppDelegate.m
- // Control Fun
- //
- // Created by Jeff LaMarche on 7/2/08.
- // Copyright __MyCompanyName__ 2008. All rights reserved.
- //
- #import "Control_FunViewController.h"
- @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:@"blueButton.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 breathe easy, %@, everything went OK.", nameField.text];
- else
- msg = @"You can breathe easy, everything went OK.";
- UIAlertView *alert = [[UIAlertView alloc]
- initWithTitle:@"Something was done"
- message:msg
- delegate:self
- 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;
- int progressAsInt = (int)(slider.value + 0.5f);
- NSString *newText = [[NSString alloc] initWithFormat:@"%d", progressAsInt];
- sliderLabel.text = newText;
- [newText release];
- }
- - (IBAction)backgroundClick:(id)sender
- {
- [nameField resignFirstResponder];
- [numberField resignFirstResponder];
- }
- - (IBAction)textFieldDoneEditing:(id)sender
- {
- [sender resignFirstResponder];
- }
- - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
- // Return YES for supported orientations
- return (interfaceOrientation == UIInterfaceOrientationPortrait);
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
- // Release anything that's not essential, such as cached data
- }
- - (void)dealloc {
- // In Chapter 4, we forgot to mention the need
- // to release the outlets, since we declared the
- // properties with the retain keyword, it is important
- // to release these here to avoid leaking memory.
- // In this example, since it is a single-view application
- // this code will only fire when the application is
- // terminating, but it is good form to keep your memory
- // clean even when it doesn't have a functional impact
- // on your application.
- [nameField release];
- [numberField release];
- [sliderLabel release];
- [leftSwitch release];
- [rightSwitch release];
- [switchView release];
- [doSomethingButton release];
- [super dealloc];
- }
- @end