|
iPhone/Touch コーディング方法 覚え書き Top … UIKit日本語資料 … UIAlertSheet? 基本情報 † 画面上にポップアップ表示するウィンドウ「アラートシート」を表示します。
メソッド †- (id)initWithFrame?:(CGRect)rect † 初期化メソッド。
- (void)setTitle:(NSString*)title † アラートシートのタイトルを設定する。
- (void)setBodyText?:(NSString*)text † シート内に表示するメッセージ文字列を設定する。
- (void)addButtonWithTitle?:(NSString*)title † ボタンをタイトル付きで追加する。
- (void)setDelegate:(id)delegate † デリゲートメッセージの送り先id。
- (void)presentSheetFromAboveView?:(UIView*)view † ベースにするビューを指定する。
- (void)popupAlertAnimated?:(BOOL)animated †アラートシートをアニメーションでポップアップ表示する。
- (void)popupAlertAnimated?:(BOOL)animated: atOffsett:(float)offset † (未調査) - (void)dismiss † アラートシートを閉じる(対象はautoreleaseでインスタンス化しておく) - (void)alertSheet:(UIAlertSheet?*)sheet buttonClicked:(int)button † デリゲート
- (void)setAlertSheetStyle?:(int)fp8 †アラートシートのデザインタイプを指定する。
共通サンプル †
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <UIKit/UIAlertSheet.h>
@interface AlertSheet : UIAlertSheet {
}
- (id)init:(id)parentID; // 画面下端タイプ
- (id)init; // ポップアップタイプ
@end
#import "AlertSheet.h"
@implementation AlertSheet
// 下端に表示するタイプ
- (id)init:(id)parentID {
[self initWithFrame: CGRectMake(0.0f,0.0f,0.0f,0.0f)];
[self setTitle: @"Info"];
[self setBodyText: @"Hello."];
[self addButtonWithTitle: @"OK"];
[self setAlertSheetStyle: 0];
[self setDelegate: self];
[self presentSheetFromAboveView: parentID]; // 必須
// popupAlertAnimatedを設定してはいけない
return self;
}
// 小窓をポップアップ表示するタイプ
- (id)init {
[self initWithFrame: CGRectMake(0.0f,0.0f,0.0f,0.0f)];
[self setTitle: @"Info"];
[self setBodyText: @"Hello."];
[self addButtonWithTitle: @"OK"];
[self setAlertSheetStyle: 0];
[self setDelegate: self];
[self popupAlertAnimated:YES]; // ここまでに他のすべてのパラメタを設定。
// presentSheetFromAboveViewを設定してはいけない
return self;
}
//-------------------------------------------------------------------
// デリゲート
- (void)alertSheet:(UIAlertSheet*)sheet buttonClicked:(int)button {
if ( button == 1 ) {
NSLog(@"Yes");
} else if ( button == 2 ) {
NSLog(@"No");
}
[sheet dismiss];
}
@end
AlertSheet* myAlertSheet = [[[ AlertSheet alloc ] init:(id)contentView] autorelease];
AlertSheet* myAlertSheet = [[[ AlertSheet alloc ] init] autorelease]; |