小编jsb*_*eJS的帖子

SceneDelegate和AppDelegate之间的区别

在我的SwiftUI项目中,我同时看到AppDelegate文件和SceneDelegate文件。

它们之间有什么区别?

例如,在 SceneDelegate

scene(_:willConnectTo:options:)
Run Code Online (Sandbox Code Playgroud)

并在 AppDelegate

application(_:didFinishLaunchingWithOptions:)
Run Code Online (Sandbox Code Playgroud)

swift swiftui

35
推荐指数
2
解决办法
8350
查看次数

SwiftUI中的约束是什么?

现在受约束的情况SwiftUI如何?难道View类型自动适应更大的设备等,或者我们应该要做的呢?

constraints ios nslayoutconstraint swift swiftui

18
推荐指数
2
解决办法
3041
查看次数

当颜色清晰 SwiftUI 时,点击操作不起作用

tapAction是不是当我的识别水龙头foregroundColorIS clear。当我去除颜色时,它工作正常。

那是我的代码:

ZStack {
    RoundedRectangle(cornerRadius: 0)
        .foregroundColor(Color.clear)
        .frame(width: showMenu ? UIScreen.main.bounds.width : 0)
        .tapAction {
            self.showMenu.toggle()
        }
    
    RoundedRectangle(cornerRadius: 5)
        .foregroundColor(Color.green)
        .shadow(radius: 5, y: 2)
        .padding(.trailing, 50)
        .frame(width: showMenu ? UIScreen.main.bounds.width : 0)
}
.edgesIgnoringSafeArea(.top)
Run Code Online (Sandbox Code Playgroud)

ios swift swiftui

11
推荐指数
3
解决办法
3700
查看次数

使用 Typescript 编译运行 Nodemon?

我希望在使用命令保存的每个文件上编译我的打字稿文件tsc

如何将 tsc 命令与 nodemon 在build:live脚本中运行的命令结合使用

"scripts": {
    "start": "npm run build:live",
    "build:live": "nodemon --watch '*.ts' --exec 'ts-node' app.ts",
 }
Run Code Online (Sandbox Code Playgroud)

此脚本会导致 nodemon 调用自身两次或三次:

"build:live": "nodemon --watch '*.ts' --exec 'ts-node app.ts & tsc'",
Run Code Online (Sandbox Code Playgroud)

javascript node.js typescript nodemon visual-studio-code

11
推荐指数
5
解决办法
9566
查看次数

'? 中的结果值 :' 表达式的类型不匹配 'some View' 和 '...'

当我尝试三元navigationBarItems以具有各种视图时出现此错误:

'? 中的结果值 :' 表达式具有不匹配的类型 'some View' 和 'ProfileImageBarButton'

@State var searchTapped: Bool = false

var body: some View {
    NavigationView {
        Text("lol")
            
   --> here i get the error .navigationBarItems(leading: searchTapped ? backButton : ProfileImageBarButton(showMenu: $showMenu))
        .navigationBarTitle(Text(""), displayMode: .inline)
    }.overlay(searchTextField)
}

private var backButton: some View {
    Image(systemName: "arrow.left")
        .foregroundColor(Color.blue)
        .onTapGesture {
            self.searchTapped = false
        }
}
Run Code Online (Sandbox Code Playgroud)

这是ProfileImageBarButton

struct ProfileImageBarButton: View {
    @Binding var showMenu: Bool
    
    var body: some View {
        Image(uiImage: UserDefaults.standard.getProfileImage()!)
            .resizable()
            .renderingMode(.original)
            .frame(width: …
Run Code Online (Sandbox Code Playgroud)

swift swiftui

8
推荐指数
2
解决办法
2426
查看次数

Clipped Image 在框架外调用 TapAction

我有一个关于图像上的 tapAction 的问题。在不应发生的剪切区域上调用 TapAction 闭包。我该怎么办?

Image(uiImage: image)
    .resizable()
    .aspectRatio(contentMode: .fill)
    .frame(height: 200, alignment: .center)
    .presentation(tapped ? Modal(Image(uiImage: image)) : nil)
    .clipped()
    .cornerRadius(10)
    .border(Color.black, width: 2, cornerRadius: 10)
    .tapAction {
        self.tapped.toggle()
    }
Run Code Online (Sandbox Code Playgroud)

结果是这样的:

在此处输入图片说明

image swift swiftui

7
推荐指数
1
解决办法
528
查看次数

ScrollView 内容未填充 SwiftUI

我有一个滚动视图,其中的内容VStack包含一个 ForEach 循环来创建一些行而不是列表。List 有一些缺点,比如分隔符。

我的问题是行没有填充滚动视图。我认为滚动视图宽度没有填满屏幕。

NavigationView {
        Toggle(isOn: $onlineStatus) {
            Text("Online Only")
        }.padding([.leading, .trailing], 15)

        ScrollView {
            VStack(alignment: .trailing) {
                ForEach(onlineStatus ? self.notes.filter { $0.dot == .green } : self.notes) { note in
                    NavigationButton(destination: Text("LOL")) {
                        CardRow(note: note)
                            .foregroundColor(.primary)
                            .cornerRadius(8)
                            .shadow(color: .gray, radius: 3, x: 0, y: -0.01)
                    }.padding([.leading, .trailing, .top], 5)
                }.animation(self.onlineStatus ? .fluidSpring() : nil)
            }
        }.padding([.leading, .trailing])

        .navigationBarTitle(Text("Your documents"))
    }
Run Code Online (Sandbox Code Playgroud)

这给了我这个结果:

在此处输入图片说明

那是我的 CardRow:

struct CardRow: View {
var note: Note

var body: some View { …
Run Code Online (Sandbox Code Playgroud)

iphone xcode ios swift swiftui

6
推荐指数
3
解决办法
7141
查看次数

在 Xcode Preview 中启用键盘

Textfield在 Xcode 预览中点击 a 时如何启用键盘。我以某种方式激活了它并单击了一些键,然后我不小心在我的 Mac 上输入了一个快捷方式,它消失了。

我怎样才能再次启用它?

xcode swiftui

6
推荐指数
2
解决办法
2123
查看次数

用于 NavigationView 的 SwiftUI 自定义后退按钮文本

按下NavigationView新按钮时,如何更改 a 中的后退按钮文本View

默认显示“返回”,但我想对其进行更改。

目前在 SwiftUI 中可以实现吗?

xcode ios swift swift5 swiftui

6
推荐指数
1
解决办法
2980
查看次数

无法在真正的iPhone上使用@ObservedObject

使用@ObservedObject它时,我无法显示我的视图。当我尝试显示该应用时,该应用崩溃了,并且出现以下错误:

线程1:EXC_BAD_ACCESS(代码= 1,地址= 0x9)

该应用程序可以在模拟器上正常运行。它只会在我的身上崩溃

iPhone 6s iOS 13测试版6

Xcode Beta 5

那是我的基本代码:

class NetworkManager: ObservableObject {

}

struct ContentView : View {
    @ObservedObject var networkManager: NetworkManager = NetworkManager()

    var body: some View {
        Text("Hi Stack")
    }
}

#if DEBUG
struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
#endif
Run Code Online (Sandbox Code Playgroud)

iphone ios swift swiftui xcode11

5
推荐指数
1
解决办法
776
查看次数