| Home 目次>ApplicationKit>NSAlert | 10.3 |
alertWithMessageText:defaultButton:alternateButton:otherButton:informativeTextWithFormat:
NSAlertのインスタンスを作ります
+(NSAlert *) alertWithMessageText:(NSString *)messageTitle
defaultButton:(NSString *)defaultButtonTitle
alternateButton:(NSString *)alternateButtonTitle
otherButton:(NSString *)otherButtonTitle
informativeTextWithFormat:(NSString *)format, ...
【返り値】 | |
| NSAlert * | 作ったアタートパネル |
| 【パラメータ】 | |
| messageTitle | タイトル |
| defaultButtonTitle | デフォルトのボタンタイトル |
| alternateButtonTitle | 代理ボタンタイトル |
| otherButtonTitle | その他のボタンタイトル |
| format, ... | 表示する文字列 |
【解説】
NSAlertのインスタンスを作ります。
アラートパネルを閉じるときの処理として - ( void )alertDidEnd:(NSAlert *)alert returnCode:( int )returnCode contextInfo:( void *)contextInfo; を実装します。
【例文】
#import "MyObject.h"
@implementation MyObject
- ( IBAction )myAction:( id )sender
{
//NSAlert のインスタンスを作ります。
NSAlert *alert = [NSAlert alertWithMessageText: @"alertWithMessageText"
defaultButton: @"defaultButton"
alternateButton: @"alternateButton"
otherButton: @"otherButton"
informativeTextWithFormat: @"informativeTextWithFormat %@" , @"text"
];
// 表示します、
[alert beginSheetModalForWindow:[sender window]
modalDelegate: self
didEndSelector: @selector (alertDidEnd:returnCode:contextInfo:)
contextInfo: nil
];
}
// 閉じる時の処理
- ( void )alertDidEnd:(NSAlert *)alert returnCode:( int )returnCode contextInfo:( void *)contextInfo;
{
NSLog( @"end" );
}
@end
![]() | |
この記事を評価してください。
| Home 目次>ApplicationKit>NSAlert | 修正日2007.5.28 |