在iOS中调用应用程序中的api委托是一种好方法吗?
我需要在应用程序启动后立即进行api调用,根据返回值,我应该决定用户是否需要继续使用该应用程序,还是应该关闭该应用程序。。我可以在app delegate中执行api调用吗。您可以显示带有加载指示器的启动屏幕并执行api调用 请查收在iOS中调用应用程序中的api委托是一种好方法吗?,ios,Ios,我需要在应用程序启动后立即进行api调用,根据返回值,我应该决定用户是否需要继续使用该应用程序,还是应该关闭该应用程序。。我可以在app delegate中执行api调用吗。您可以显示带有加载指示器的启动屏幕并执行api调用 请查收 当您从API获得响应时,您可以调用splashImageView.removeFromSuperview()让用户使用应用程序我假设您所说的AppDelegate是指打开应用程序时调用的didfishLaunchingWithOptions函数。它主要用于设置应用程
当您从API获得响应时,您可以调用
splashImageView.removeFromSuperview()
让用户使用应用程序我假设您所说的AppDelegate是指打开应用程序时调用的didfishLaunchingWithOptions
函数。它主要用于设置应用程序的初始配置。尽管可能存在一些异常,但它不应等待异步操作继续。您可以做的是,对于入口点,创建一个视图控制器(或视图)作为等待状态,并在其中进行API调用。收到响应后,您可以导航到应用程序的详细页面,或向用户显示信息性弹出窗口并关闭应用程序。我该怎么做?将调用应用程序委派intialy@HariharasudhanJ,我用一个例子编辑了答案
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
let splashImage = UIImage.autoAdjustNamed("Default.png")
let splashImageView = UIImageView(image: splashImage)
window.rootViewController?.view.addSubview(splashImageView)
window.rootViewController?.view.bringSubviewToFront(splashImageView)
UIView.animate(
withDuration: 1.5,
delay: 2.0,
options: .curveEaseInOut,
animations: {
splashImageView.alpha = 0.0
let x: CGFloat = -60.0
let y: CGFloat = -120.0
splashImageView.frame = CGRect(
x: x,
y: y,
width: splashImageView.frame.size.width - 2 * x,
height: splashImageView.frame.size.height - 2 * y)
})
return true
}