我使用 SwiftUI 3.0、Swift 5.5 和 Xcode 13.2,在 iOS 15.3 iPhone 设备和 iOS 15.2 iPhone 模拟器上进行了测试。
我已经测试了以下内容。
这是一个视图,带有一个 TextField、一个焦点状态和一个.toolbar
import SwiftUI
struct test: View {
@State private var name = "Taylor Swift"
@FocusState var isInputActive: Bool
var body: some View {
TextField("Enter your name", text: $name)
.textFieldStyle(.roundedBorder)
.focused($isInputActive)
.toolbar {
ToolbarItemGroup(placement: .keyboard) {
Spacer()
Button(name) {
isInputActive = false
}
}
}
}
}
struct test_Previews: PreviewProvider {
static var previews: some View {
test()
}
}
Run Code Online (Sandbox Code Playgroud)
它按预期完美工作,并且显示一个按钮,其中包含在 TextField 中键入的任何文本。 …
既然苹果已经拿走了 Plist,自然它就改变了我们向应用程序添加自定义字体的方式。在我们将文件添加到我们的包中并为其以及我们的 plist 和 viola 设置属性之前..
现在我很好奇..是否可以在不添加此处所示的自定义 plist 的情况下完成,或者这是唯一的选择?
我已将 mac 更新到 11.6,将 xcode 更新到 13.0。Realm 无法编译,所以我用 carthage 将其更新到 v10.15.1。现在,我在应用程序启动后立即收到此运行时错误:
Library not loaded: @rpath/Realm.framework/Realm
Referenced from: /Users/username/Library/Developer/Xcode/DerivedData/appname/Build/Products/Debug-iphonesimulator/RealmSwift.framework/RealmSwift
Reason: tried: '/Users/username/Library/Developer/Xcode/DerivedData/appname/Build/Products/Debug-iphonesimulator/Realm.framework/Realm' (file does not start with MH_MAGIC[_64], file does not start with MH_MAGIC[_64], fat file, but missing compatible architecture (have 'x86_64,i386', need 'x86_64')), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/Realm.framework/Realm' (no such file), '/usr/lib/swift/Realm.framework/Realm' (no such file), '/Users/username/Library/Developer/CoreSimulator/Devices/33E61712-D8A9-4D7E-A260-5C096BE08A82/data/Containers/Bundle/Application/AC700919-F431-446F-8BEF-FF8D8E5F5BF9/appname.a
Run Code Online (Sandbox Code Playgroud)
我想这里的关键部分是file does not start with MH_MAGIC[_64],但我找不到任何关于该错误的有用信息。
我尝试嵌入库并关闭嵌入,不会影响任何内容。
我正在尝试在 Xcode 13 和 SwiftUI 中构建仅横向的应用程序。我注意到,即使我未选中“纵向”方向,该应用程序仍将以纵向模式运行。我无法强制该应用程序在横向模式下工作。
这是设备方向设置:
这是简单的 hello world SwiftUI:
import SwiftUI
struct ContentView: View {
var body: some View {
Text("Hello, world!")
.padding()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Run Code Online (Sandbox Code Playgroud)
预期的:
当设备处于纵向模式时,“Hello world”顺时针旋转 90 度。强制用户将设备旋转到横向模式才能正确查看。
实际的:
“Hello world”在纵向模式下仍然可以正确呈现。为什么?
我用 UIAlertControllerStyleActionSheet 风格显示 UIAlertController 。使用 XCode 13 UIAlertController 标题和消息构建时,在 iPhone 12 上不起作用。它在其他设备上工作。之前在 iPhone 12 上运行的代码相同。
-(void)alertSheetUI{
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:@"Static Title" message:@"Static Message" preferredStyle:UIAlertControllerStyleActionSheet];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Data 1" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Data 2" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Data 3" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
[[[UIApplication sharedApplication] delegate].window.rootViewController dismissViewControllerAnimated:YES completion:^{
}];
}]];
[[[UIApplication sharedApplication] delegate].window.rootViewController presentViewController:actionSheet animated:NO completion:nil];
});}
Run Code Online (Sandbox Code Playgroud)
iPhone 12
视图层次结构将标题和消息显示为白色。所以只有标题和消息不可见。我尝试使用以下代码将标题和消息设置为绿色使用属性文本。但标题和消息颜色在其他设备上也不会更新。其他设备显示为灰色。 …
刚刚下载了最新的 Xcode 13 beta 3,但我无法预览工作:
PlatformDoesNotHaveAgentsError:缺少 iOS 所需的组件
Xcode 缺少在 iOS 上预览所需的组件
==================================
| HumanReadableSwiftError | | 位置错误:noBundle
重新启动没有帮助。
在 MBP Intel、macOS 11.4 上测试
不知道是我mac的问题还是这个版本引入的bug。
任何线索?
编辑:看起来只有在您选择 iOS 15 模拟器时才有效,您不能再使用 iOS 14.x 版本...
我正在使用 Xcode 13.0 (13A233) 在配备 M1 芯片的 Macbook 上开发一个应用程序。将 pod 更新到最新版本后,pod 抱怨错误
CompileSwiftSources 正常的arm64 com.apple.xcode.tools.swift.compiler(在项目“Pods”的目标“Alamofire”中)
并且不为真实设备或模拟器构建。
我在项目中包含以下 pod:
我已经为主项目和所有 pod 项目应用了以下解决方案:
您可以在此屏幕截图上查看错误详细信息。
我知道与这些问题相关的答案有很多,但我已经尝试了每个问题,当我无法用这些答案解决问题时,我在这里发布问题。
自从将我的 iPhone 升级到 iOS 15 并在 Mac 上升级到 Xcode 13 后,我在使用 Xcode 测试/调试任何 SwiftUI 应用程序时遇到了问题。即使是带有简单“hello world”示例的新 Xcode 项目,在按下 Xcode“开始”按钮时也会以这种方式运行(无论目标是模拟器还是装有 iOS 15 的物理 iPhone)。
应用程序似乎已正确上传到目标,但目标在显示应用程序屏幕之前显示空白屏幕超过一分钟(分钟)。
当 Xcode 调试器断开连接并在目标(无论是模拟器还是物理 iPhone)上手动启动应用程序时,它似乎工作正常(首先不会出现任何白屏)。
我的所有 SwiftUI 应用程序(以及简单的 Xcode Swift“Hello World”示例)都有相同的行为,这些应用程序已经工作了很长时间,没有任何问题。
我仍然安装了 Xcode 12.5,它现在表现出相同的行为(即使目标操作系统是 iOS 14.5),并且应用程序已上传到我的 iOS 15 iPhone。
基本上不可能测试和调试存在此问题的应用程序。
有没有其他人有这个问题?
有什么已知的解决方案或建议吗?
谢谢!
我在使用该方法时遇到了麻烦,它似乎在iOS 15setNavigationBarHidden上无法正常工作。
我目前正在使用这个结构:
ViewController, 需要navigationBarViewController,当我点击 a 时从上一个推送UIButton,这不需要navigationBar 在以前版本的iOS上,我只是调用setNavigationBarHidden(true, animated: true)了viewWillAppear第二个方法ViewController,一切都按预期工作,但从新版本的 iOS 来看,这不会正确发生。
现在navigationBar不能正确隐藏,我必须实现我想要的行为的唯一方法是使用navigationBar.isHidden = true,不幸的是,这导致我在两个控制器之间出现草率且不那么流畅的动画。
我该如何解决这个问题?