WEB开发网
开发学院手机开发iPhone 开发 iPhone常用控件、UIActionSheet、UIAlertView 阅读

iPhone常用控件、UIActionSheet、UIAlertView

 2010-12-18 08:05:25 来源:WEB开发网   
核心提示:- (IBAction) segmentChanged: (id)sender;- (IBAction) buttonPressed: (id)sender;@end UntitledViewController.h// Untitled Created by Elf Sundae on 11/10/10.// Cop

- (IBAction) segmentChanged: (id)sender;

- (IBAction) buttonPressed: (id)sender;

@end

//

// UntitledViewController.h

// Untitled

//

// Created by Elf Sundae on 11/10/10.

// Copyright 2010 www.cnBlogs.com/ElfSundae. All rights reserved.

//

#import

#define kSegmentIndex_Switches 0

#define kSegmentIndex_Button 1

@interface UntitledViewController : UIViewController

{

UISwitch * leftSwitch;

UISwitch * rightSwitch;

UIButton * doSomethingButton;

}

@property (retain, nonatomic) IBOutlet UISwitch *leftSwitch;

@property (retain, nonatomic) IBOutlet UISwitch *rightSwitch;

@property (retain, nonatomic) IBOutlet UIButton *doSomethingButton;

- (IBAction) switchChanged: (id)sender;

- (IBAction) segmentChanged: (id)sender;

- (IBAction) buttonPressed: (id)sender;

@end

OBJECTIVE-C CODE :UntitledViewController.m

// UntitledViewController.m

// Untitled

//

// Created by Elf Sundae on 11/10/10.

// Copyright 2010 www.cnBlogs.com/ElfSundae. All rights reserved.

//

#import "UntitledViewController.h"

@implementation UntitledViewController

@synthesize leftSwitch;@synthesize rightSwitch;@synthesize doSomethingButton;// 属性on:获取开关的状态是否为on

// 方法setOn:设置开关的状态

- (IBAction) switchChanged: (id)sender{ UISwitch *whichSwitch = (UISwitch *)sender; BOOL setting = whichSwitch.on; [leftSwitch setOn:setting animated:YES]; [rightSwitch setOn:setting animated:YES];}- (IBAction) segmentChanged: (id)sender{ switch ([sender selectedSegmentIndex]) { case kSegmentIndex_Switches:

leftSwitch.hidden = NO; rightSwitch.hidden = NO; doSomethingButton.hidden =

上一页  1 2 3 4 5  下一页

Tags:iPhone 常用 控件

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接