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

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

相关推荐
mCell2 小时前
谁在为 AI 开车:Agent 浏览器生态调研(2026)
chrome·macos·agent
2501_9160074711 小时前
申请 iOS 推送证书并配置 APNs 群发推送教程
android·ios·小程序·https·uni-app·iphone·webview
weixin_4038101312 小时前
iOS自动化脚本怎么避免风控?无屏幕镜像截图原理详解
ios·自动化·跨境电商·苹果群控·苹果投屏·多媒体运营
wangruofeng13 小时前
3 步把 MacBook 变成 7×24 远程主机,人在外面随时接管桌面
ios·agent·mac
weixin_4038101313 小时前
iOS免越狱自动化蓝牙HID方案:不装代理也能跑脚本
运维·ios·自动化·跨境电商·ai智能体·ios投屏·苹果投屏
sudebao点com1 天前
一次“Google 能打开,FlexTV 打不开”的 DNS 故障排查:从 curl 超时到完整证据链
windows·macos·https·cdn·dns·nslookup·网络排错
GitLqr1 天前
Flutter 3.47 与 Dart 3.13:你必须了解的迁移指南
flutter·ios·dart
冯汉栩1 天前
Swift Control View,Label渐变颜色(源码)
开发语言·ios·swift
jike_20261 天前
iPhone日历查看会议纪要APP推荐:按日期查找历史录音更方便
ios·语音识别·iphone
EXI-小洲1 天前
MacOS 微服务网关双雄:Nacos + Higress 安装与 Dubbo 配置实战
macos·微服务·nacos·dubbo