我想从appdelegate设置初始viewcontroller.我找到了一个非常好的答案,但它是在Objective C中,我很难在swift中实现同样的功能.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *viewController = // determine the initial view controller here and instantiate it with [storyboard instantiateViewControllerWithIdentifier:<storyboard id>];
self.window.rootViewController = viewController;
[self.window makeKeyAndVisible];
return YES;
}
Run Code Online (Sandbox Code Playgroud)
有人能帮忙吗?
我希望初始Viewcontroller依赖于使用条件语句满足的某些条件.
I am using Xcode 5 in a newly created app and when I just create it I go for the run button e click on it, then the project gets built but it does not show in the iOS Simulator and I get the following message:
Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' -
perhaps the designated entry point is not set?
Run Code Online (Sandbox Code Playgroud)
I've Googled about it of course and everybody points out that this is happening because …
I am currently getting a blank screen with Xcode 11, Target iOS 13.0 (the app works fine with all below versions iOS 12.1 till 12.4), I want to make my App work for both iOS users above 12.1 and also 13.0 currently getting blank screen despite adding the below SceneDelegate to my existing project and
adding App Manifest file
import UIKit
import SwiftUI
@available(iOS 13.0, *)
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: …
Run Code Online (Sandbox Code Playgroud) 我有两个故事板,其中一个默认名为Main,另一个我刚刚添加的名为Admin.
Main用于客户,Admin用于应用程序的所有者.
我想知道如何以编程方式设置初始/主界面故事板.
PS我知道如何通过xcode更改它,但不知道编程.