How to add subview inside UIAlertView for iOS 7?

前端 未结 6 2062
悲哀的现实
悲哀的现实 2020-11-27 15:41

I am having an application on iTunes store which displays some UILabel and UIWebView on UIAlertView. According to session video,

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-27 16:16

    You can really change accessoryView to customContentView in iOS7 (and it seems that in iOS8 as well) UIAlertView

    [alertView setValue:customContentView forKey:@"accessoryView"];
    

    Try this code:

    UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"TEST" message:@"subview" delegate:nil cancelButtonTitle:@"NO" otherButtonTitles:@"YES", nil];
    UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 80, 40)];
    [av setValue:v forKey:@"accessoryView"];
    v.backgroundColor = [UIColor yellowColor];
    [av show];
    

    Remember that you need set custom accessoryView before the call [alertView show]

    enter image description here

提交回复
热议问题