简体   繁体   English

如何删除Xcode 13中复制的预览手机?

[英]How to remove a copied preview phone in Xcode 13?

When I click the following button on the top of a preview phone, Xcode copies the preview phone for me.当我点击预览手机顶部的以下按钮时,Xcode 会为我复制预览手机。 So if there is only one preview phone before clicking the button, there are two afterward.因此,如果在单击按钮之前只有一部预览手机,则之后会有两部。

预览电话

My question is: How to remove the copied preview phone?我的问题是:如何删除复制的预览手机?

Previews only happen because your code says they should happen.预览只会发生,因为你的代码说它们应该发生。 All this button really does is to modify the code that generates the preview(s).这个按钮真正做的就是修改生成预览的代码。 For example:例如:

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        Group {
            ContentView()
            ContentView()
        }
    }
}

See how it says ContentView() twice?看看它是怎么说ContentView()两次的? That's two previews.这是两个预览。 To remove the second preview, revert the change.要删除第二个预览,请还原更改。 For example:例如:

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM