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

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

相关推荐
追光天使1 天前
Mac M1 源码安装FFmpeg,开启enable-gpl 和 lib x264
macos·ffmpeg
会飞的爱迪生1 天前
mac和linux传输文件
linux·运维·macos
数据的世界012 天前
解决.NET程序通过网盘传到Linux和macOS不能运行的问题
linux·运维·服务器·macos
wn5312 天前
【浏览器 - Mac实时调试iOS手机浏览器页面】
前端·macos·ios·智能手机·浏览器
shichen5012 天前
MacOS 如何映射快捷键
macos·mac·策略模式
小鹿撞出了脑震荡3 天前
Effective Objective-C 2.0 读书笔记—— 方法调配(method swizzling)
ios·objective-c·swift
小鹿撞出了脑震荡3 天前
Effective Objective-C 2.0 读书笔记—— 消息转发
ios·objective-c·swift
一丝晨光3 天前
Cocoa和Cocoa Touch是什么语言写成的?什么是Cocoa?编程语言中什么是框架?为什么苹果公司Cocoa类库有不少NS前缀?Swift编程语言?
macos·ios·objective-c·cocoa·swift·uikit·cocoa touch
程序媛-徐师姐4 天前
解决MacOS安装软件时提示“打不开xxx软件,因为Apple无法检查其是否包含恶意软件”的问题
macos·无法检查其是否包含恶意软件·打不开xxx软件
会飞的爱迪生4 天前
mac安装dockerdesktop优化
macos