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

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

相关推荐
2501_9159184113 分钟前
只有 Flutter IPA 文件,通过多工具组合完成有效混淆与保护
android·flutter·ios·小程序·uni-app·iphone·webview
软件小滔3 小时前
Mac 上看图?从需求出发的功能匹配
经验分享·macos·mac·应用推荐
软件小滔4 小时前
MacOS 26.0 网速监控我试了十几款,从系统API到可视化实现
经验分享·macos·mac·应用推荐
川石课堂软件测试6 小时前
Android和iOS APP平台测试的区别
android·数据库·ios·oracle·单元测试·测试用例·cocoa
liusheng6 小时前
Capacitor + React 的 iOS 侧滑返回手势
前端·ios
你好龙卷风!!!6 小时前
rabbitMQ入门 (mac)
macos·rabbitmq·ruby
2501_915918417 小时前
除了 Perfdog,如何在 Windows 环境中完成 iOS App 的性能测试工作
android·ios·小程序·https·uni-app·iphone·webview
七月巫山晴8 小时前
【iOS】NSString&NSRange&NSCharacterSet
ios·cocoa·iphone
h-189-53-6712078 小时前
2026(原创)Guideline 4.3(a) - Design - Spam苹果上架iOS审核被拒AppStore卡审解决办法思路
ios
zhimingwen10 小时前
【開發筆記】修復 macOS 上 JADX 啟動崩潰並實現快速啟動
android·macos·反編譯