我正在使用Xcode 11(beta3)并为iOS 13构建应用程序。在我的项目中,我创建了UIWindowSceneDelegate在Info.plist中声明它的委托方法。现在,我可以创建多个窗口(和UIScene)。
现在我已经没有单个窗口了,如何访问rootViewController?我需要它来获取对它所持有的对象和范围的一些引用。
在我的AppDelegate window is nil和ViewController(子视图控制器)实例中,我尝试使用,self.view.window.rootViewController但发现这viewDidLoad()还为时过早(我认为),并且该窗口仍为nil,可以在中工作viewDidAppear(),但是我不需要每次都进行此过程视图控制器出现的时间。
这种处理应用程序场景的新方法的最佳实践是什么?
这是我的AppDelegate:
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
return true
}
func application(_ application: UIApplication,
configurationForConnecting connectingSceneSession: UISceneSession,
options: UIScene.ConnectionOptions) -> UISceneConfiguration {
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
Run Code Online (Sandbox Code Playgroud)
我的SceneDelegate:
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// yes it's empty, I'm using storyboard
}
Run Code Online (Sandbox Code Playgroud) 我刚刚下载了Xcode 11 Beta 4,当我想构建自己的Swift 4项目时,我得到了:
UILaunchImages已被弃用,请改用启动故事板
我该如何解决?
有什么方法可以在TabbedView选中或取消选中SwiftUI 中的选项卡项时更改它的图像?
TabbedView(selection: $selection) {
Text("Home").tabItem {
Image(systemName: "house")
Text("Home")
}.tag(0)
Text("Away").tabItem {
Image("away")
Text("Away")
}.tag(1)
}
Run Code Online (Sandbox Code Playgroud)
我试过在网上搜索,但没有找到答案。我正在使用 Xcode 11 beta 4。
我正在尝试使用滚动视图制作通向目标视图的导航视图,其中目标视图的导航标题将朝着内联显示模式设置动画,或者至少滚动到导航栏本身的后面。
基本上我试图复制标准音乐应用程序的行为,特别是当你从图书馆转到歌曲时。
在那里你有源视图(库),它有自己的标题,在滚动时动画进入内联显示模式。当您点击歌曲时,您还会获得带有新标题(歌曲)的列表,该列表也会在滚动时以动画方式进入内联显示模式。
所以我有带有 NavigationBarTitle 的主 NavigationView。我移动到带有自己的 NavigationBarTitle 和一些长内容列表的 destinationView。在滚动时,主导航视图的 NavigationBarTitle 更改为内联显示模式,但目标视图的 NavigationBar 表现得很奇怪:它基本上是一个没有背景和动画的叠加层。
如果您将目标视图的 NavigationBarTitle 全部删除,只会让事情变得更糟。似乎它添加了另一个透明的 NavigationBar,里面什么都没有。
还尝试为导航栏添加背景,查看文档,但没有找到解决方案。
不确定我是做错了什么,还是只是 SwiftUI 或 Xcode 的测试版错误。
import UIKit
struct ContentView: View {
var body: some View {
NavigationView{
List(0..<20) { item in
NavigationLink(destination: DetailedView()) {
Text("Next view")
}
}
.navigationBarTitle("Source View")
}
}
}
struct DetailedView: View {
var body: some View {
List(0...25) { number in
Text("This is \(number)'th row")
}
.navigationBarTitle(Text("Destination View"))
// comment out line above to see empty …Run Code Online (Sandbox Code Playgroud) 我们正在使用 xcode 11 beta 5 中的催化剂 swift 将我们的 iOS 应用程序转换为 macCatalyst 兼容。
我们遇到了默认 DatePicker 未显示在窗口中的问题。
我正在为 mac 尝试这个解决方案,它会在视图中添加日期选择器,但我想要另一个合适的解决方案。还有什么建议吗?
func datepickerWillLoad() {
self.datePicker.datePickerMode = .date
self.datePicker.maximumDate = Date()
self.datePicker.backgroundColor = UIColor.Theme.lightBackground
self.datePicker.setValue(UIColor.Theme.whiteColor, forKeyPath: "textColor")
self.datePicker.addTarget(self, action: #selector(didChangedDatePickerValue), for: .valueChanged)
//if user open picker and without change click on done
self.dateOfBirthTextField.addTarget(self, action: #selector(didChangedDatePickerValue), for: .editingDidEnd)
#if targetEnvironment(macCatalyst)
datePicker.frame = CGRect(x: 0, y: self.view.frame.height - 200 , width: self.view.frame.width, height: 200)
self.view.addSubview(datePicker)
#else
self.dateOfBirthTextField.inputView = datePicker
#endif
}
Run Code Online (Sandbox Code Playgroud) 我有一个带有多个 viewController 和一个 tabBarController 的故事板应用程序。到目前为止,navigationBar 的标题颜色为白色。现在我正在使用 Xcode 11 beta 6 和 iOS 13 beta 8 进行测试,标题为黑色。在装有 iOS 12 的设备上,标题仍然是白色的。我试图在故事板的导航控制器的导航栏中设置标题颜色。但这没什么区别。我还尝试在每个视图中更改标题颜色,但有时不起作用。在开始使用 iOS 13 进行测试时,我不得不更改我的代码以更改状态栏的背景颜色。代码是这样的:
self.tabBarController.title = NSLocalizedString(@"AppTitle",nil);
NSShadow *shadow = [[NSShadow alloc] init];
shadow.shadowColor = [UIColor clearColor];
shadow.shadowOffset = CGSizeMake(0, 1);
[self.navigationController.navigationBar setBarTintColor:COLOR_HEADER_LIGHT];
if (@available(iOS 13, *))
{
UINavigationBarAppearance *navBar = [[UINavigationBarAppearance alloc] init];
navBar.backgroundColor = COLOR_HEADER_LIGHT;
self.navigationController.navigationBar.standardAppearance = navBar;
self.navigationController.navigationBar.scrollEdgeAppearance = navBar;
}
else
{
UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
statusBar.backgroundColor = COLOR_HEADER_LIGHT;
}
} …Run Code Online (Sandbox Code Playgroud) UIDocumentBrowserViewController在iOS 13上进行测试时,我遇到了一个非常奇怪的问题。importHandler(newDocumentURL, .move)似乎无缘无故地崩溃了:
[DocumentManager] Cannot create urlWrapper for url file:///.../tmp/23720D22-BC1D-4E7B-A7AE-A1C8B0293F9E.txt.
error Error Domain=NSPOSIXErrorDomain Code=22 "couldn't issue sandbox extension com.apple.app-sandbox.read-write for '/.../tmp/23720D22-BC1D-4E7B-A7AE-A1C8B0293F9E.txt':
Invalid argument" UserInfo={NSDescription=couldn't issue sandbox extension com.apple.app-sandbox.read-write for '/.../tmp/23720D22-BC1D-4E7B-A7AE-A1C8B0293F9E.txt': Invalid argument}.
Run Code Online (Sandbox Code Playgroud)
这是一个复制的两步过程:
在 documentBrowser(_: , didRequestDocumentCreationWithHandler:)
let newDocumentURL: URL? =
URL(fileURLWithPath: NSTemporaryDirectory())
.appendingPathComponent(UUID().uuidString)
.appendingPathExtension("txt")
// Set the URL for the new document here. Optionally, you can present a template chooser before calling the importHandler.
// Make sure the importHandler is always called, even if the …Run Code Online (Sandbox Code Playgroud)从运行时从Xcode 10.3升级到Xcode 11以来,还有其他人得到这个react-native run-ios吗?
CoreData: annotation: Failed to load optimized model at path '/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/Frameworks/InstrumentsPackaging.framework/Versions/A/Resources/XRPackageModel.momd/XRPackageModel 9.0.omo'
error Could not find iPhone X simulator
Run Code Online (Sandbox Code Playgroud) 由于 Xcode 11 已将 Version 更改为 $(MARKETING_VERSION) & Build 为 $(CURRENT_PROJECT_VERSION)
构建设置中有新字段
由于
xcrun agvtool new-version
xcrun agvtool new-marketing-version
不能像在 Xcode 10 上那样完美地工作
我试过这个/sf/answers/4071527561/但没有用
我只能从中获得正确的价值
echo $versionNumber
echo $buildNumber
Run Code Online (Sandbox Code Playgroud)
但是我怎样才能为它设置新的值呢?
xcode11 ×10
ios ×6
ios13 ×3
swiftui ×2
catalyst ×1
react-native ×1
shell ×1
swift ×1
swift5.1 ×1
uidatepicker ×1
uikitformac ×1
versioning ×1
xcode ×1
xcode10 ×1
xctest ×1
xctestcase ×1