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

iPhone常用控件、UIActionSheet、UIAlertView

 2010-12-18 08:05:25 来源:WEB开发网   
核心提示:actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex{ if (buttonIndex != [actionSheet cancelButtonIndex]) { NSString *text
actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex{ if (buttonIndex != [actionSheet cancelButtonIndex]) { NSString *text = [[NSString alloc] initWithFormat:@"test alert"]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Something was done." message:text delegate:self cancelButtonTitle:@"OK!" otherButtonTitles:nil]; [alert show]; [alert release]; [text release]; }}//- (void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex//{// NSLog(@"%d",buttonIndex);//}

示例:

视图有一个UISegmentedControl,"Switches"下有两个UISwitch

"Button"下有一个“Do Something"的UIButton

触摸"Do Something"Button时弹出UIActionSheet

触摸选择"Yes,I'm sure."时弹出 UIAlertView

OBJECTIVE-C CODE :UntitledViewController.h

// 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;

上一页  1 2 3 4 5  下一页

Tags:iPhone 常用 控件

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