3 回答

TA貢獻1921條經驗 獲得超9個贊
不,不可能。
顯示啟動屏幕時,您的應用程序將處于加載狀態。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions顯示啟動屏幕時,甚至都不會完全執行。
很明顯,您沒有訪問您的應用的權限,因此在這一點上您無法執行任何代碼。

TA貢獻2036條經驗 獲得超8個贊
我試圖在這里做同樣的事情。:)
我真的很喜歡其中一些應用程序,其中每次啟動應用程序時,它們都會做一些動態的問候文字和圖像,例如“今天看起來很好!”,“今天是星期五,美好的一天”等,這是非??蓯?。
我做了一些搜索,下面是如何做:(我的代碼是XCode 7,帶有launchscreen.xib文件)
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var customizedLaunchScreenView: UIView?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
application.statusBarHidden = true
// customized launch screen
if let window = self.window {
self.customizedLaunchScreenView = UIView(frame: window.bounds)
self.customizedLaunchScreenView?.backgroundColor = UIColor.greenColor()
self.window?.makeKeyAndVisible()
self.window?.addSubview(self.customizedLaunchScreenView!)
self.window?.bringSubviewToFront(self.customizedLaunchScreenView!)
UIView.animateWithDuration(1, delay: 2, options: .CurveEaseOut,
animations: { () -> Void in
self.customizedLaunchScreenView?.alpha = 0 },
completion: { _ in
self.customizedLaunchScreenView?.removeFromSuperview() })
}
return true
}
// other stuff ...
}
只要做你想要什么都顯示,文本,圖像,動畫等內部customizedLaunchScreenView這里。
在啟動結束時,只需使用alpha值更改淡出此自定義UIView,然后將其完全刪除即可。
多么酷?。课医^對喜歡它!
希望能幫助到你。

TA貢獻2037條經驗 獲得超6個贊
我也在努力實現這一目標。我嘗試了以下方法,它延遲了幾秒鐘,但對我有用。
在項目設置中創建并設置啟動屏幕。
使用自定義類(SplashViewController)創建一個視圖控制器,并將其設置為情節提要中的起始視圖控制器。
在其中添加容器視圖并將其設置為全屏。
將嵌入式segue設置為Storyboard參考。
選擇Storyboard Reference,然后在Attribute inspector中的StoryBoard屬性中設置啟動屏幕。
在SplashViewController中執行您想要的任何操作(播放動畫或會話檢查等),并在完成后執行segue。
希望能幫助到你!
- 3 回答
- 0 關注
- 582 瀏覽
添加回答
舉報