ios 对话框UIAlertController放 tableview

news/2024/7/20 21:48:35 标签: ios, cocoa, macos
//强弱引用
#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];
    
}

在这里插入图片描述
问题来了,对话框 既然 不在屏幕中间。

解决办法

-(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);
根据各个手机去适配吧。调整到合适的位置。


http://www.niftyadmin.cn/n/5176521.html

相关文章

在Gradio实现两个下拉框进行联动案例解读:change/click/input实践(三)

本文的代码来自ChuanhuChatGPT,通过拆解写得比较好的gradio项目,可以更快理解gradio的一些使用。 ChuanhuChatGPT整体页面效果是比较合理的: 1 下拉框联动效果的解读 本篇是将一个其中【对话】中的【Prompt加载】小模块抽取出来并稍稍修改…

【MySQL】事务(上)

文章目录 事务概念什么是事务?为什么要有事务?事务的版本支持事务的提交方式事务常见操作方式基本操作 事务概念 mysql 本身内部采用 多线程的方式,来实现数据存储 相关的工作 就注定对数据 有并发访问的场景 为了解决这类问题,就…

(C)程序运行结果题

1. # include < stdio . h >void main () {int x , i ;for ( i 1; i <100; i ) {X i ;if ( x %20)if ( x %30)if ( x %70)printf ("% d ", x ); }} 答案&#xff1a;28 70 2. # include < stdio . h >int main () { int a [3][3]((1,2,3),(4,6,2)…

前端中 JS 发起的请求可以暂停吗?

给大家推荐一个实用面试题库 1、前端面试题库 &#xff08;面试必备&#xff09; 推荐&#xff1a;★★★★★ 地址&#xff1a;web前端面试题库 这个问题非常有意思&#xff0c;我一看到就想了很多可以回复的答案&#xff0c;但是评论区太窄&#xff0c;就直接开…

低代码平台如何提高开发效率?

目录 一、开发工具&#xff1a;JNPF 二、产品分析 1可视化应用开发 2流程管理 3特别支持整个平台源码合作 三、使用技巧 四、总结 在当今快速发展的软件开发领域&#xff0c;提高生产效率和质量是每个开发团队追求的目标。JNPF&#xff08;Java Non-Enterprise Applicat…

互联网Java工程师面试题·微服务篇·第一弹

目录 ​编辑 1、您对微服务有何了解&#xff1f; 2、微服务架构有哪些优势&#xff1f; 3、微服务有哪些特点&#xff1f; 4、设计微服务的最佳实践是什么&#xff1f; 5、微服务架构如何运作&#xff1f; 6、微服务架构的优缺点是什么&#xff1f; 7、单片&#xff0c…

springboot集成MongoDB并在代码中实现增删改查相关语法

在项目中使用MongoDB文档数据库很频繁&#xff0c;存储一些非结构化数据、第三方回调数据、日志、以及一些不是那么实时需要的数据等等&#xff0c;当然document也可以是结构化的数据&#xff1b; 在职场中会有一些新入职的同事或者同为程序员的小伙伴初用MongoDB不太了解如何…

9.25 广读论文 思想汇总

数据集MIMIC-VI Learning Patient Static Information from Time-series EHR and an Approach for Safeguarding Privacy and Fairness The dataset analyzed in this study can be found in https://physionet.org/content/mimiciv/2.2/ and https://eicu-crd.mit.edu/about/…