How to add a UITableView inside the UIAlertView in

2019-01-15 10:43发布

I want to add the UItableview inside the alert view..

I have tried to add a table view as a sub view of alert view, it's not working. Can you give me some code or sample link for that?

How can i do that?

Thanks

5条回答
做自己的国王
3楼-- · 2019-01-15 10:48

Instead of UIAlertView + UITableView is much better to use UIActionSheet.

查看更多
等我变得足够好
4楼-- · 2019-01-15 10:50

Is this really what you want?

An alert is very obtrusive, and quite alarming to the user. Alerts are modal and should be use with great discretion. Maybe one of these could be a better solutions:

  • Navigate to a new screen with the options in a table view there. Like most of the Settings app do.
  • Use a UISegmentedControl, like for example in the settings of a WiFi network.
  • Have the options in a UIPopoverController if on iPad.
  • Rephrase the option so a UISwitch is the logical control.
查看更多
Bombasti
5楼-- · 2019-01-15 10:54

Its working in my case

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"title" message:@"click for submission \n\n\n\n "delegate:self  cancelButtonTitle:@"click for submission"
otherButtonTitles:nil];

    table = [[UITableView alloc]initWithFrame:CGRectMake(10, 40, 264, 120)];
    table.delegate = self;
    table.dataSource = self;
    [alert addSubview:table];

    [alert show];

    [table release];

    [alert release];        
查看更多
你好瞎i
6楼-- · 2019-01-15 11:10

you can use CAAlertView "https://github.com/chandanankush/CAAlertView" for both tableView listing and datePicker

查看更多
登录 后发表回答