我是SwiftUI的新手(就像大多数人一样),试图弄清楚如何删除我在NavigationView中嵌入的List上方的空白。
在此图像中,您可以看到列表上方有一些空白

我要完成的是

我试过使用
.navigationBarHidden(true)
Run Code Online (Sandbox Code Playgroud)
但这并没有进行任何明显的更改。
我目前正在这样设置我的navigationView
NavigationView {
FileBrowserView(jsonFromCall: URLRetrieve(URLtoFetch: applicationDelegate.apiURL))
.navigationBarHidden(true)
}
Run Code Online (Sandbox Code Playgroud)
其中FileBrowserView是具有列表和像这样定义的单元格的视图
List {
Section(header: Text("Root")){
FileCell(name: "Test", fileType: "JPG",fileDesc: "Test number 1")
FileCell(name: "Test 2", fileType: "txt",fileDesc: "Test number 2")
FileCell(name: "test3", fileType: "fasta", fileDesc: "")
}
}
Run Code Online (Sandbox Code Playgroud)
我确实要注意,这里的最终目标是您将能够单击这些单元格来更深地浏览到文件树,因此在更深层的导航上应该在栏上显示“后退”按钮,但是我不需要在我的初始视图中排名最高。
我正在设计一个应用程序,其中包括检索 JSON 数据和在 FileBrowser 类型视图中显示检索项目列表的功能。在此视图中,用户应该能够单击文件夹以深入了解文件树,或单击文件以查看有关该文件的一些元数据。
我观察到,在此过程中,当我单击一个文件或文件夹然后返回并再次单击它时,不会触发 NavigationLink,并且在单击不同的 NavigationLink 之前我一直停留在视图上。
这是演示此问题的 gif。
如图所示,当我点击 BlahBlah 时,我正在激活 NavigationLink 并被带到 BlahBlah,然后当我返回并尝试重新导航到 BlahBlah 时,它变成灰色,表明我点击了它...... . 单击 TestFile 修复了这个问题,并允许我导航回 BlahBlah。
列表项由以下结构组成
private struct FileCell{
var FileName: String
var FileType: String
var FileID: String = ""
var isContainer: Bool
}
private struct constructedCell: View{
var FileType: String
var FileName: String
var FileID: String
var body: some View {
return
HStack{
VStack(alignment: .center){
Image(systemName: getImage(FileType: FileType)).font(.title).frame(width: 50)
}
Divider()
VStack(alignment: .leading){
Text(FileName).font(.headline)
.multilineTextAlignment(.leading)
Text(FileID)
.font(.caption)
.multilineTextAlignment(.leading)
}
} …Run Code Online (Sandbox Code Playgroud) 在 swiftUI 中调用警报的方法应该比以往更简单,一个简单的例子是
struct ContentView: View {
@State private var showingAlert = false
var body: some View {
Button(action: {
self.showingAlert = true
}) {
Text("Show Alert")
}
.alert(isPresented: $showingAlert) {
Alert(title: Text("Important message"), message: Text("Wear sunscreen"), dismissButton: .default(Text("Got it!")))
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是,即使我正在调用警报并且可以验证正在调用该方法,我的警报也不会显示。
在我的代码中,我有以下结构
private struct resetButton: View {
@State var isResetting = false
var body: some View {
Button("Reset"){
self.isResetting = true
}.alert(isPresented: $isResetting) {
print("We get here")
return
Alert(title: Text("Are you sure?"), message: Text("This will erase your …Run Code Online (Sandbox Code Playgroud) 不久前,我尝试使用以下方式提交应用程序Xcode version 11.1 (11A1027),但收到了一封来自 Apple 的电子邮件,其中包含以下消息:
ITMS-90424:无效的 Swift 支持 - SwiftSupport 文件夹为空。使用当前公共 (GM) 版本的 Xcode 重新构建您的应用程序并重新提交。
据我所知,11A1027已经是发布版本了,所以我不太确定为什么需要使用 Xcode 的 GM 版本。有人有什么主意吗?
我尝试了其他帖子中建议的一些方法,但不知何故无法解决它。
这是 Xcode 中的错误吗?
所以我知道有很多关于堆栈溢出的答案可以忽略 bash 脚本中的错误。不过,它们似乎都不适用于 source 命令。
我已经尝试过久经考验的 source ../bin/activate || true
我set -e在运行命令之前尝试过设置
我试过了 source ../bin/activate 2>&1 /dev/null
我set +e在运行命令之前尝试过设置。这也不起作用。
但是在这段代码的每次运行中,我都会收到
run.01: line 12: ../bin/activate: 没有那个文件或目录
这个问题的上下文是我正在创建一个运行一些 python 代码的简单 bash 脚本。指示用户如何创建特定的虚拟环境,如果他们正确设置,此行将自动激活它,否则,这应该忽略无法激活运行并在当前激活的任何环境中继续运行命令。
# Try virtual environment
source ../bin/activate || true
## Run.
code="../src-01/driver.v01.py"
## --------------------
graphInputFile="undirected_graph_01.inp"
graphType="undirected"
srcColId="0"
desColId="1"
degreeFind="2"
outFile="count.undirected.num.nodes.out"
python $code -inpGraphFile $graphInputFile -graphFormat $graphType -colSrcId $srcColId -colDesId $desColId -degreeFind $degreeFind -output_file $outFile
Run Code Online (Sandbox Code Playgroud)
无论命令是否source ../bin/activate成功,python 命令都应该执行。我有点不明白为什么这些解决方案都不起作用,目前我假设在这种情况下source可能会做一些与正常命令不同的事情。
编辑:
我#!/bin/bash -x按照要求将shebang添加到我的文件中,但这没有做任何事情。
这是我运行此脚本时的确切终端输出。 …