something

 

#import <uikit> 

@class somethingViewController;

@interface somethingAppDelegate : NSObject <uiapplicationdelegate> 
{
    UIWindow *window; 
    somethingViewController *viewController; 
} 

@property (nonatomic, retain) IBOutlet UIWindow *window; 
@property (nonatomic, retain) IBOutlet somethingViewController *viewController;

@end

 

#import "somethingAppDelegate.h" 
#import "somethingViewController.h" 

@implementation somethingAppDelegate 
      @synthesize window; 
      @synthesize viewController;

  - (void)applicationDidFinishLaunching:(UIApplication *)application { 
          // Override point for customization after app launch 
          [window addSubview:viewController.view];
          [window makeKeyAndVisible];

     } 

  - (void)dealloc { 
           [viewController release]; 
           [window release];
           [super dealloc]; 
      } 

    @end  

 

 

 

 #import <uikit> 

 @interface somethingViewController : UIViewController <uiactionsheetdelegate> 
   {
       IBOutlet UITextField *name; 
       IBOutlet UITextField *pwd; 
       IBOutlet UISlider *slider;
       IBOutlet UILabel *label; 
       IBOutlet UISegmentedControl *segmentControl; 
       IBOutlet UIView *swithView; 
       IBOutlet UISwitch *leftSwitch; 
       IBOutlet UISwitch *rightSwitch;
       IBOutlet UIButton *button;
  }

@property (nonatomic ,retain) UITextField *name ;
@property (nonatomic,retain) UITextField *pwd;
@property (nonatomic,retain) UISlider *slider;
@property (nonatomic,retain) UILabel *label; 
@property (nonatomic,retain) UIButton *button;
@property (nonatomic,retain) UISegmentedControl *segmentControl;
@property (nonatomic,retain) UIView *swithView; 
@property (nonatomic,retain ) UISwitch *leftSwitch; 
@property (nonatomic,retain) UISwitch *rightSwitch;

-(IBAction) textFieldDoneEditing:(id) sender;
-(IBAction) sliderChange:(id) sender;
-(IBAction ) segmentChange:(id) sender; 
-(IBAction ) buttonDoneEditing:(id) sender;
-(IBAction) swithChange:(id) sender; 
-(IBAction) buttonClick:(id) sender; 

@end 

 

 

 

#import "somethingViewController.h"

 @implementation somethingViewController

 @synthesize name; 
 @synthesize pwd; 
 @synthesize slider;
 @synthesize label;
 @synthesize swithView; 
 @synthesize segmentControl; 
 @synthesize rightSwitch; 
 @synthesize leftSwitch; 
 @synthesize button;

-(IBAction) textFieldDoneEditing:(id) sender{ 
      [sender resignFirstResponder]; 
   }

 -(IBAction ) buttonDoneEditing:(id) sender{ 
        [name resignFirstResponder]; 
        [pwd resignFirstResponder]; 
   }

-(IBAction) sliderChange:(id) sender{ 
        UISlider *s=(UISlider *)sender; 
        int intValue=(int)(s.value + 0.5f);
        NSString *v=[[NSString alloc] initWithFormat:@"%d",intValue];
        [label setText:v ];
        [v release]; 
    } 

-(IBAction ) segmentChange:(id) sender{ 
      UISegmentedControl *seg=(UISegmentedControl *) sender; 
      NSInteger segment=[seg selectedSegmentIndex]; 
      if(segment==0){
             [swithView setHidden:NO]; 
       }else { 
              [swithView setHidden:YES];
          }  
   } 


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



-(IBAction) buttonClick:(id) sender{ 
  NSString *msg; 
  if([[name text] length] >0){ 
           msg=[[NSString alloc] initWithFormat:@"%@",[name text]]; 
     }
          else 
     {
         msg=@"elsefee-----";
      } 

UIActionSheet *actionSheet=[[UIActionSheet alloc] initWithTitle:@"titititiitititiltltltltl" 
                                                      delegate:self 
                                                                     cancelButtonTitle:msg 
                                                                                     destructiveButtonTitle:@"确认"  
                                                                     otherButtonTitles:@"other1",@"other2",@"other3",nil]; 
     [actionSheet showInView:self.view]; 
     [actionSheet release];
     [msg release]; 
} 



- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex{ 
    NSLog(@"didDismissWithButtonIndex",buttonIndex); 
    NSLog(@"cancelbutton===%d",[actionSheet cancelButtonIndex]); 
    NSLog(@"----------------");

    UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"alerttttt"
                                                           message:@"message-------" 
                                                          delegate:nil 
                                                          cancelButtonTitle:@"cancelbutton" 
                                                         otherButtonTitles:@"oo1",@"oo2",@"oo33",nil];

   [alert show]; 
   [alert release]; 

}


/* 
// The designated initializer. Override to perform setup that is required before the view is loaded. 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
          if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
                 // Custom initialization 
           } 
           return self; 
     } 

*/


 /* 
    // Implement loadView to create a view hierarchy programmatically, without using a nib. 
  - (void)loadView { 

            } 
 */



 /* 
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. 
- (void)viewDidLoad { 
          [super viewDidLoad]; 
      } 

*/



 /* 
// Override to allow orientations other than the default portrait orientation. 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
        // Return YES for supported orientations 
         return (interfaceOrientation == UIInterfaceOrientationPortrait);
    } */ 

- (void)didReceiveMemoryWarning { 
      // Releases the view if it doesn't have a superview. 
       [super didReceiveMemoryWarning];
     // Release any cached data, images, etc that aren't in use. 
   }


 - (void)viewDidUnload { 
    // Release any retained subviews of the main view. 
   // e.g. self.myOutlet = nil;
  } 

- (void)dealloc { 
          [super dealloc];
          [name release];
          [pwd release]; 
          [label release]; 
          [slider release];
          [swithView release]; 
          [leftSwitch release]; 
          [rightSwitch release];
          [segmentControl release]; 
          [button release];
  }

 @end

 

你可能感兴趣的:(in)