how to add a UITableView into UIAlertView in iOS 7

前端 未结 3 862
误落风尘
误落风尘 2020-12-19 22:37

did some googling around saw that subview is no longer supported in iOS 7.

Some ppl recommend creating custom view, but i am not sure how can i do that.

Here

3条回答
  •  旧巷少年郎
    2020-12-19 23:31

    You can change accessoryView to any own customContentView in a standard alert view in iOS7

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

    Note that you must call this before [alertView show].

    Simplest illustrating example:

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

    enter image description here

    Real tableView as the subview of UIAlertView example:

    enter image description here

提交回复
热议问题