-2
-(void) alertView: (UIAlertView *) alertVw clickedButtonAtIndex:(NSInteger)buttonIndex
{
    NSString *str = [NSString stringWithFormat:@"%d 。", buttonIndex];
    UIAlertView *newAlertVw = [[UIAlertView alloc] initWithTitle:@"INFO" message:str delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [newAlertVw show];
}


UIAlertView *alertVw = [[UIAlertView alloc] initWithTitle:@"TITLE"
                                                      message:@"box message"
                                                     delegate:self
                                            cancelButtonTitle:@"hide"
                                            otherButtonTitles:@"T1", @"T2", nil];
    [alertVw show];

ユーザーが otherButtons の 1 つに触れた場合、はい、そのユーザーがどのボタンに触れたかがわかります。では、ユーザーがタッチしたばかりのボタンのタイトルを取得するにはどうすればよいですか? ありがとう。

4

3 に答える 3

0

実際、デリゲート メソッドを使用する場合は、 を使用する必要があります-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex

そしてそうではない

-(void)alertView:(UIAlertView*)alertView didDismissWithButton At Index:(NSInteger)buttonIndex

参照: https://developer.apple.com/library/ios/documentation/uikit/reference/UIAlertViewDelegate_Protocol/UIAlertViewDelegate/UIAlertViewDelegate.html#//apple_ref/occ/intfm/UIAlertViewDelegate/alertView:didDismissWithButtonIndex :

パンチョのタイプミスだと思います。

于 2014-07-30T12:28:46.967 に答える