最終更新:2013-01-11 (金) 08:49:50 (4116d)  

UIAlertView
Top / UIAlertView

メッセージの表示

-(void)showMessage{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"title!!" 
		message:@"hogehoge"
		delegate:self
		cancelButtonTitle:@"Cancel"
		otherButtonTitles:@"OK", nil];
    [alert show];
}

//ボタンが押されたときに呼び出されるデリゲート
// buttonIndex は左側のボタンから 0, 1, 2 ... となる  
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if(buttonIndex == 1){
        NSLog(@"OK");
    }else{
        NSLog(@"Cancel");
    }
}

[alert setNumberFfNows?:3] (3はボタンの数)と書くと、縦にボタンを並べることができる。しかし、これはドキュメントには記載されておらず警告が出る。(参考URL)

UIAlertViewDelegate

  • alertView:clickedButtonAtIndex?

関連