ios之AlertView

(1)

@interface ViewController ()<UIAlertViewDelegate>


        



(2)

UIAlertView *alert = [[UIAlertView alloc]

                              initWithTitle:nil

                              message:nil

                              delegate:self

                              cancelButtonTitle:nil

                              otherButtonTitles:@"电子用品",@"学习用品",@"生活用品",nil];

[alert show];


(3)

#pragma  mark - alertViewDelegate

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

    

    

    NSLog(@"%ld",(long)buttonIndex);

    UIButton *myButton1 = (UIButton *)[self.view viewWithTag:602];

    NSArray * arr = @[@"电子用品",@"学习用品",@"生活用品"];

    [myButton1 setTitle:arr[buttonIndex] forState:0];

    self.typeStr = arr[buttonIndex];

    

    

}







猜你喜欢

转载自blog.csdn.net/dangbai01_/article/details/80004139