我们有一个世博会管理应用程序。最初我们在文件中设置expo.name了\xe2\x80\x99 。我们成功地将其发布到两个商店 - App Store 和 Google Play。Bridge - Debit Cardapp.json
但后来我们注意到应用程序显示名称(设备桌面上应用程序图标正下方的应用程序名称)看起来很笨拙。看起来就像BridgeDe...在 iOS 上一样。
因此,我们将 expo.name 更改为 simple Bridge,重新构建独立应用程序,并再次将新的二进制文件发布到两个应用程序商店中。
Google Play 刚刚吃掉了新的二进制文件,没有任何问题,新的短应用程序名称出现在 Android 设备上。
\n但我们在上传文件时\xe2\x80\x99无法通过Apple验证.ipa。Transporter我们在 Mac 上使用应用程序。它显示一个错误:
\n\nITMS-90129:捆绑包使用已使用的捆绑包名称或显示名称。
\n
但我们的 AppStore 中没有类似名称的应用程序。
\n我们尝试返回expo.name旧值并将 Bridge 值Bridge - Debit Card添加CFBundleDisplayName(以及稍后)到 中,但没有运气:在 AppStore 中发布的应用程序很好(旧值通过了验证),但应用程序图标下的名称很长且被截断。所以,这个选项根本没有起作用,没有任何改变。CFBundleNameexpo.ios.infoPlistexpo.name
这是app.json我们应用程序的一个示例:
{\n "expo": {\n "name": "Bridge - …Run Code Online (Sandbox Code Playgroud) 我想向我的应用程序添加一个 UIMenu,我正在练习它,现在有一个问题是否可以将其位置设置UIMenu为比按钮当前显示的位置稍高:
正如您在这张照片中看到的,菜单当前覆盖了选项卡栏,我想将其设置为比选项卡栏高一点。这是我的代码:
let menu = UIMenu(title: "", children: [
UIAction(title: NSLocalizedString("Gallery", comment: ""), image: UIImage(systemName: "folder"), handler: {
(_) in
self.loadPhotoGallery()
})
])
btnMenuExtras.menu = menu
Run Code Online (Sandbox Code Playgroud) 我知道习俗是如何ButtonStyle运作的。但我确实想要一个完全可重用的自定义按钮。
又名带有文本和图标的按钮,应用了一些样式。
我知道如何使用带有文本属性的 ButtonStyle 来实现此目的,但我认为这完全是对按钮样式的滥用。
但我不想HStack在我的应用程序中复制具有大内容的按钮。
对于此类用例,您有什么建议?Button网上似乎没有人在 SwiftUI 中对 a 进行子类化。
每当我将设备旋转到横向并再次返回时,顶部 NavigationView(包括标题和后退按钮)都会被夹在状态栏下方。
struct ContentView: View {
var body: some View {
NavigationView {
ScrollView {
VStack {
ForEach(0..<15) { _ in
Text("Filler")
.frame(maxWidth: .infinity)
.background(Color.green)
.padding()
}
}
}
.navigationBarTitle("Data")
}
}
}
Run Code Online (Sandbox Code Playgroud)
只要内容是可滚动的,就会发生故障。我最初是在使用List. 如果我先单击一行,转到弹出视图,然后旋转设备,或者只是在主屏幕中旋转回来,都没有关系。
struct ContView: View {
let data = ["One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen"]
var body: some View {
NavigationView {
List {
ForEach(data, id: \.self) { word in
NavigationLink(destination:
Text("Link")
) …Run Code Online (Sandbox Code Playgroud) 我有一个List从我的people数组中获取数据并显示它们的名称。
我还过滤了列表,以便它只显示包含文本字段文本的名称,即searchText. 这是我的代码:
struct Person: Identifiable {
let id = UUID() /// required for the List
var name = ""
}
struct ContentView: View {
@State var searchText = ""
var people = [ /// the data source
Person(name: "Alex"),
Person(name: "Ally"),
Person(name: "Allie"),
Person(name: "Bob"),
Person(name: "Tim"),
Person(name: "Timothy")
]
var body: some View {
VStack {
TextField("Search here", text: $searchText) /// text field
.padding()
List {
ForEach(
people.filter { person in /// …Run Code Online (Sandbox Code Playgroud) 我正在尝试为 SwiftUI 进度视图中的进度条设置动画。我发现了一些可以帮助解决这个问题的东西,但是在 UIProgressView 中,我试图用 SwiftUI 来完成这个任务。目前的方法:
ProgressView(value: 0.25).animation(Animation.easeInOut(duration: 3))
Run Code Online (Sandbox Code Playgroud)
问题是整个视图都是动画的。我只想要进度条动画。
我制作了一个自定义集合视图流布局,可以在“胶片”和“列表”布局之间切换(带动画)。但是在向边缘单元格添加了一些花哨的动画后,切换动画中断了。这是目前的样子,没有这些变化:
动画很好很流畅,对吧?这是当前的工作代码(这里是完整的演示项目):
enum LayoutType {
case strip
case list
}
class FlowLayout: UICollectionViewFlowLayout {
var layoutType: LayoutType
var layoutAttributes = [UICollectionViewLayoutAttributes]() /// store the frame of each item
var contentSize = CGSize.zero /// the scrollable content size of the collection view
override var collectionViewContentSize: CGSize { return contentSize } /// pass scrollable content size back to the collection view
/// pass attributes to the collection view flow layout
override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
return layoutAttributes[indexPath.item] …Run Code Online (Sandbox Code Playgroud) 我想通过将函数传递给 .background() 来更改文本背景颜色,如下所示,颜色的值为 0 或 1 或 2 将取决于数据库的数据。我该如何修复它:
import SwiftUI
struct ContentView: View {
@State var color = 0;
var body: some View {
Text("Hello, World!")
.background(changeBkColor(int : self.$color))
}
}
func changeBkColor(int : color)
{
if(color == 1)
{
return Color.red;
}
else if(color == 2)
{
return Color.green;
}
else
{
return Color.blue;
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Run Code Online (Sandbox Code Playgroud) 我知道,这是“无法在 iOS XX 中工作”问题之一,但我完全陷入困境......
所以我有一个ObservableObject继承自 的类NSObject,因为我需要监听 的委托方法UISearchResultsUpdating。
class SearchBarListener: NSObject, UISearchResultsUpdating, ObservableObject {
@Published var searchText: String = ""
let searchController: UISearchController = UISearchController(searchResultsController: nil)
override init() {
super.init()
self.searchController.searchResultsUpdater = self
}
func updateSearchResults(for searchController: UISearchController) {
/// Publish search bar text changes
if let searchBarText = searchController.searchBar.text {
print("text: \(searchBarText)")
self.searchText = searchBarText
}
}
}
struct ContentView: View {
@ObservedObject var searchBar = SearchBarListener()
var body: some View {
Text("Search text: …Run Code Online (Sandbox Code Playgroud) 我最初问这个问题:
在那里,我有一个List没有部分的。我正在过滤它们,以便它只显示包含 .txt 文件中文本的行TextField。解决方案是将所有内容包装List在Section.
不幸的是,我现在需要过滤Sections。这是我的代码:
struct Group: Identifiable {
let id = UUID() /// required for the List
var groupName = ""
var people = [Person]()
}
struct Person: Identifiable {
let id = UUID() /// required for the List
var name = ""
}
struct ContentView: View {
@State var searchText = ""
var groups = [
Group(groupName: "A People", people: [
Person(name: "Alex"),
Person(name: "Ally"), …Run Code Online (Sandbox Code Playgroud) ios ×10
swift ×9
swiftui ×7
swiftui-list ×2
expo ×1
javascript ×1
react-native ×1
uikit ×1
uimenu ×1