Home > Tags > AlertBox
AlertBox
iPhoneアプリ アラートボックスを表示する。
- 2010-01-17 (日)
- Object-C | iPhone | iPhone SDK 3
AlertBoxAppDelegate.h
#import <UIKit/UIKit.h>
@class AlertBoxViewController;
@interface AlertBoxAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
AlertBoxViewController *viewController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet AlertBoxViewController *viewController;
@end
AlertBoxViewController.h
#import <UIKit/UIKit.h>
@interface AlertBoxViewController : UIViewController {
}
- (IBAction) displayView:(id) sender;
@end
AlertBoxViewController.m
//アラートボックスを表示するdisplayViewメソッド
-(IBAction) displayView:(id) sender{
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"アラート画面"
message:@"ボタンを押しました"
delegate:self
cancelButtonTitle:@"閉じる"
otherButtonTitles:nil];
[alert show];
[alert release];
}
後は、InterfaceBuilderで、Alertを表示させるトリガーのボタンと、
File’s OwnerをCtrl+ドラッグで結んで、「displayView」を結びます。
- Comments: 1
- Trackbacks: 0
Home > Tags > AlertBox
