ios 对话框UIAlertController放 tableview

objectivec 复制代码
//强弱引用
#define kWeakSelf(type)__weak typeof(type)weak##type = type;
-(void) showUIAlertTable
{
    kWeakSelf(self)
    UIAlertController *alert = [UIAlertController      alertControllerWithTitle:NSLocalizedString(@"select_stu", nil)   message:nil   preferredStyle:UIAlertControllerStyleAlert];
    CGRect     frame = self.view.bounds;
    frame = CGRectInset(frame, 0, 0);
    UITableView *tableView2 = [[UITableView alloc] initWithFrame:frame style:UITableViewStylePlain];
    tableView2.dataSource = self;
    tableView2.delegate = self;
    [tableView2 registerClass:[DevicelistCell class] forCellReuseIdentifier:@"deviceCell"];
    [alert.view addSubview:tableView2];
    [self presentViewController:alert animated:NO completion:nil];
    
}


问题来了,对话框 既然 不在屏幕中间。

解决办法

objectivec 复制代码
-(void) showUIAlertTable
{
    kWeakSelf(self)
    UIAlertController *alert = [UIAlertController      alertControllerWithTitle:NSLocalizedString(@"select_stu", nil)   message:nil   preferredStyle:UIAlertControllerStyleAlert];
    CGRect     frame = self.view.bounds;
    frame = CGRectInset(frame, -50, -300);
    UITableView *tableView2 = [[UITableView alloc] initWithFrame:frame style:UITableViewStylePlain];
    tableView2.dataSource = self;
    tableView2.delegate = self;
    [tableView2 registerClass:[DevicelistCell class] forCellReuseIdentifier:@"deviceCell"];
    [alert.view addSubview:tableView2];
    [self presentViewController:alert animated:NO completion:nil];
    
}

frame = CGRectInset(frame, -50, -300);

根据各个手机去适配吧。调整到合适的位置。

相关推荐
Keya21 分钟前
解决 pod install 警告信息显示不完全的方法
ios·xcode·cocoapods
随笔记2 小时前
uniapp开发的小程序输入框在ios自动填充密码,如何欺骗苹果手机不让自动填充
前端·ios·app
蓝纹绿茶3 小时前
【Mac】实现Docker下载安装【正在逐步完善】
macos·docker·容器
unicrom_深圳市由你创科技4 小时前
Unity开发如何解决iOS闪退问题
unity·ios·蓝桥杯
TE-茶叶蛋4 小时前
iOS打包流程
ios
Daniel_Coder5 小时前
iOS Widget 开发-1:什么是 iOS Widget?开发前的基本认知
ios·swiftui·swift·widget
AirDroid_cn20 小时前
OPPO手机怎样被其他手机远程控制?两台OPPO手机如何相互远程控制?
android·windows·ios·智能手机·iphone·远程工作·远程控制
小弟调调20 小时前
Vidwall: 支持将 4K 视频设置为动态桌面壁纸,兼容 MP4 和 MOV 格式
macos·swiftui·桌面应用·macos app
杂雾无尘21 小时前
开发者必看,全面解析应用更新策略,让用户无法拒绝你的应用更新!
ios·xcode·swift