How to add a UITableView inside the UIAlertView in iPhone?

℡╲_俬逩灬. 提交于 2019-11-28 00:12:58

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];        

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.

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!