トップ 編集 凍結解除 差分 バックアップ 添付 リロード 新規 一覧 単語検索 最終更新 ヘルプ

iPhone/Touch コーディング方法 覚え書き TopUIKit日本語資料 … UIAlertSheet?


基本情報

 画面上にポップアップ表示するウィンドウ「アラートシート」を表示します。

  • スーパークラス
     UIView

メソッド

- (id)initWithFrame?:(CGRect)rect

 初期化メソッド。

  • (CGRect)rect : 適当な値をセット(無視される)。

- (void)setTitle:(NSString*)title

 アラートシートのタイトルを設定する。

  • (NSString*)title : タイトルの文字列

- (void)setBodyText?:(NSString*)text

 シート内に表示するメッセージ文字列を設定する。

  • (NSString*)text : メッセージの文字列

- (void)addButtonWithTitle?:(NSString*)title

 ボタンをタイトル付きで追加する。

  • (NSString*)title : タイトル文字列

- (void)setDelegate:(id)delegate

 デリゲートメッセージの送り先id。

  • (id)delegate : 送り先のインスタンスid

- (void)presentSheetFromAboveView?:(UIView*)view

 ベースにするビューを指定する。

  • (UIView*)view : ベースにするビューのid(通常はself)

- (void)popupAlertAnimated?:(BOOL)animated

 アラートシートをアニメーションでポップアップ表示する。

  • (BOOL)animated : YES:アニメーションでポップアップ NO:しない(???)

- (void)popupAlertAnimated?:(BOOL)animated: atOffsett:(float)offset

 (未調査)

- (void)dismiss

 アラートシートを閉じる(対象はautoreleaseでインスタンス化しておく)

- (void)alertSheet:(UIAlertSheet?*)sheet buttonClicked:(int)button

 デリゲート

  • (UIAlertSheet?*)sheet : このデリゲートを呼んだインスタンスのid
  • buttonClicked:(int)button : タッチされたボタンの番号

- (void)setAlertSheetStyle?:(int)fp8

 アラートシートのデザインタイプを指定する。

  • (int)fp8 : デザイン番号   (0:灰色地に白テキスト 1:黒地に白テキスト 2:半透明黒地に白テキスト)

共通サンプル

  • AlertSheet?.h
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <UIKit/UIAlertSheet.h>

@interface AlertSheet : UIAlertSheet {
}
- (id)init:(id)parentID; // 画面下端タイプ
- (id)init; // ポップアップタイプ

@end
  • AlertSheet?.m
#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
  • 使い方 1(下端に表示するタイプ)
AlertSheet* myAlertSheet = [[[ AlertSheet alloc ] init:(id)contentView] autorelease];
  • 使い方 2(ポップアップタイプ)
AlertSheet* myAlertSheet = [[[ AlertSheet alloc ] init] autorelease];

トップ   編集 凍結解除 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2008-02-28 (木) 14:45:15 (882d)