Loading [MathJax]/jax/output/CommonHTML/config.js
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >iPad上的ActionSheet未正确显示SwiftUI

iPad上的ActionSheet未正确显示SwiftUI
EN

Stack Overflow用户
提问于 2020-12-16 13:29:35
回答 1查看 552关注 0票数 5

我正在尝试让我的用户在ActionSheet中选择拍照或从库中挑选

它在Iphone上运行良好,但在Ipad上效果不佳

在Ipad上: ActionSheet在屏幕顶部,不可读...

我在StackOverflow上读到的关于这个问题的所有问题都是关于crash的(这不是我的情况),或者比SwiftUI更老

我的代码:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
     struct AjoutView: View {
    @State private var image : Image?
    @State private var shouldPresentImagePicker = false
    @State private var shouldPresentActionScheet = false
    @State private var shouldPresentCamera = false
    
    var body: some View {
     VStack{
      ...
     }
        .sheet(isPresented: $shouldPresentImagePicker, onDismiss: loadImage) {
            SUImagePickerView(sourceType: self.shouldPresentCamera ? .camera : .photoLibrary, image: self.$image, isPresented: self.$shouldPresentImagePicker, dispId: disp.id)
                }
        .actionSheet(isPresented: $shouldPresentActionScheet) { () -> ActionSheet in
                    ActionSheet(title: Text("Ajouter une photo"), buttons: [ActionSheet.Button.default(Text("Prendre une photo"), action: {
                        self.shouldPresentImagePicker = true
                        self.shouldPresentCamera = true
                    }), ActionSheet.Button.default(Text("Importer depuis mes photos"), action: {
                        self.shouldPresentImagePicker = true
                        self.shouldPresentCamera = false
                    }), ActionSheet.Button.cancel()])
    
            }
    }
}

我的代码中缺少什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-12-16 13:44:40

将它附加到View中的某个东西上,比如让它显示出来的Button

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
struct ASSample: View {
    @State var shouldPresentActionScheet1: Bool = false
    @State var shouldPresentActionScheet2: Bool = false

    var body: some View {
        VStack{
            Button("show-sheet1", action: {
                self.shouldPresentActionScheet1.toggle()
            })
            .actionSheet(isPresented: $shouldPresentActionScheet1) { () -> ActionSheet in
                ActionSheet(title: Text("Ajouter une photo"), buttons: [ActionSheet.Button.default(Text("Prendre une photo"), action: {
                    //self.shouldPresentImagePicker = true
                    //self.shouldPresentCamera = true
                }), ActionSheet.Button.default(Text("Importer depuis mes photos"), action: {
                    //self.shouldPresentImagePicker = true
                    //self.shouldPresentCamera = false
                }), ActionSheet.Button.cancel()])
                
            }

            Spacer()
            Button("show-sheet2", action: {
                self.shouldPresentActionScheet2.toggle()
            })
            .actionSheet(isPresented: $shouldPresentActionScheet2) { () -> ActionSheet in
                ActionSheet(title: Text("Ajouter une photo"), buttons: [ActionSheet.Button.default(Text("Prendre une photo"), action: {
                    //self.shouldPresentImagePicker = true
                    //self.shouldPresentCamera = true
                }), ActionSheet.Button.default(Text("Importer depuis mes photos"), action: {
                    //self.shouldPresentImagePicker = true
                    //self.shouldPresentCamera = false
                }), ActionSheet.Button.cancel()])
                
            }
        }
        
    }
    
}

struct ASSample_Previews: PreviewProvider {
    static var previews: some View {
        ASSample()
    }
}
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65324275

复制
相关文章
TA-Lib MA_Type
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
多凡
2019/11/01
1.5K0
linux系统,python3.7环境安
获取源码 wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
py3study
2020/01/16
6550
python 安装talib模块
找到 talib 库下载源:https://www.lfd.uci.edu/~gohlke/pythonlibs/#ta-lib
青山师
2023/05/05
2.3K0
使用TA-Lib在vn.py上开发CTA交易策略
作为一套被业界广泛应用的开源技术分析库(包含技术指标计算和K线模式识别等),TA-Lib自2001年发布以来已经有了十多年的历史。TA-Lib中一共包含大约125个技术指标的计算函数,同时提供了包括C/C++、Java、Perl、Python等多种语言的API。
用Python的交易员
2018/07/26
1.9K0
使用TA-Lib在vn.py上开发CTA交易策略
Gentoo 安装Cacti 错误
Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /var/www/localhost/htdocs/cacti/lib/functions.php on line 486 02/11/2014 06:25:10 AM - SYSTEM STATS: Time:0.1238 Method:cmd.php Processes:1 Threads:N/A Hosts:2 HostsPerProcess:2 DataSources:1 RRDsProcessed:1 OK u:0.00 s:0.00 r:0.02 解决如下
星哥玩云
2022/06/29
9790
Npm 安装提示 EUNSUPPORTEDPROTOCOL 错误
从上面的错误信息我们来抓重点看就是第一行 verbose stack Error: Unsupported URL Type "npm:": npm:@elastic/elasticsearch@7.13.0
HoneyMoose
2021/09/11
7.7K0
Npm 安装提示 EUNSUPPORTEDPROTOCOL 错误
Hue安装错误集锦
2.Access denied for user ‘root’@‘localhost’ (using password: NO)
Maynor
2021/04/09
6230
pycharm安装包错误
然后输入命令:pip install pandas -i https://pypi.douban.com/simple,
全栈程序员站长
2022/08/30
1.3K0
pycharm安装包错误
drupal安装配置错误
#########################################################################
全栈程序员站长
2022/09/09
2.4K0
torchvision 安装出现错误[通俗易懂]
错误: (base) C:\Users****_admin>pip install torchvision Collecting torchvision Using cached https://files.pythonhosted.org/packages/fb/01/03fd7e503c16b3dc262483e5555ad40974ab5da8b9879e164b56c1f4ef6f/torchvision-0.2.2.post3-py2.py3-none-any.whl Requirement already satisfied: pillow>=4.1.1 in d:\python\lib\site-packages (from torchvision) (5.4.1) Collecting torch (from torchvision) Using cached https://files.pythonhosted.org/packages/5f/e9/bac4204fe9cb1a002ec6140b47f51affda1655379fe302a1caef421f9846/torch-0.1.2.post1.tar.gz ERROR: Complete output from command python setup.py egg_info: ERROR: Traceback (most recent call last): File “”, line 1, in File “C:\Users****_A~1\AppData\Local\Temp\pip-install-1_kj1dql\torch\setup.py”, line 11, in raise RuntimeError(README) RuntimeError: PyTorch does not currently provide packages for PyPI (see status at https://github.com/pytorch/pytorch/issues/566).
全栈程序员站长
2022/09/12
1.6K0
Linux安装redis和redis安装常见错误
执行完 make 命令后,redis-6.0.9 的 src 目录下会出现编译后的 redis 服务程序 redis-server,还有用于测试的客户端程序 redis-cli:
全栈程序员站长
2022/07/11
1.5K0
CAD 2020 安装时出现“安装错误1603:安装过程中的致命错误”
错误1603是Microsoft Windows Installer(MSI)生成的一般错误。此错误倾向于与系统相关,而不是与特定软件相关联。以下是1603错误的常见示例:
知识兔下载
2023/01/31
9.3K0
pycharm快速安装库_pycharm安装库错误
由于pycharm自带的pip源网站是国外网址,这就导致了许多国内用户在pycharm中下载其他软件包速度极慢,有时还会跳出下载失败的界面。
全栈程序员站长
2022/09/25
7860
pycharm快速安装库_pycharm安装库错误
quartus ii运行错误_安装quartus时弹出错误
Info: ******************************************************************* Info: Running Quartus II 64-Bit Analysis & Synthesis Info: Version 11.0 Build 157 04/27/2011 SJ Full Version Info: Processing started: Thu May 15 13:09:59 2014 Info: Command: quartus_map –read_settings_files=on –write_settings_files=off simulate -c simulate Info: Parallel compilation is enabled and will use 2 of the 2 processors detected Info: Found 1 design units, including 1 entities, in source file simulate.v Info: Found entity 1: modelsim_test Error: Top-level design entity “simulate” is undefined
全栈程序员站长
2022/11/04
5.1K0
quartus ii运行错误_安装quartus时弹出错误
lnmp 1.3 安装 typecho 404错误
作者:matrix 被围观: 3,109 次 发布时间:2017-01-02 分类:零零星星 | 无评论 »
HHTjim 部落格
2022/09/26
4330
ETL详细安装教程(常见错误)
接着我们在选择一个安装目录,注意尽量不要安装在C盘。经过上述操作后,得到如下图,然后再次点击下一步;
数据分析与统计学之美
2021/11/25
1K0
Windows下安装Nginx错误总结
1:CreateFile()“xxxxx” failed (3: The system cannot find the path specified)
凯哥Java
2022/12/16
2K0
Windows下安装Nginx错误总结
解决MacOS pip安装mysqlclient错误
错误详情: Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting mysqlclient Downloading https://pypi.tuna.tsinghua.edu.cn/packages/4d/38/c5f8bac9c50f3042c8f05615f84206f77f03db79781db841898fde1bb284/mysqlclient-1.4.4.tar.gz (86kB) |███
小贝壳
2020/03/05
2.8K0
Apache安装时错误解析
1.error: mod_deflate has been requested but can not be built due to prerequisite failures 解决办法是: yum install -y zlib-devel 为了避免在make的时候出现错误,所以最好是提前先安装好一些库文件: yum install -y pcre pcre-devel apr apr-devel ---- 2.APACHE安装error: cannot install 'libaprutil-1.la
老七Linux
2018/05/31
1.4K0
点击加载更多

相似问题

Google Colaboratory安装错误: TA-Lib

133

安装Ta-lib会导致gcc错误。

60

无法安装TA-LIB?

12

安装TA-lib问题

254

使用pipenv安装ta-lib时返回错误

234
添加站长 进交流群

领取专属 10元无门槛券

AI混元助手 在线答疑

扫码加入开发者社群
关注 腾讯云开发者公众号

洞察 腾讯核心技术

剖析业界实践案例

扫码关注腾讯云开发者公众号
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文