HOME > 最前面のUIViewControllerを取得する
アプリの一番最前面に張り付いているUIViewControllerを取得したかったので調べてみました。ObjectiveCのソースがありましたので、 Swiftに修正してみました。
参考:最前面のUIViewControllerを取得する
参考:最前面のViewControllerを探す!!!
参考:Get top most UIViewController
staticクラスの関数にしている例ですが、keyWindowから取得してwhileで一番上のUIViewControllerを返します。
static func getTopMostViewController()->UIViewController{
var tc = UIApplication.sharedApplication().keyWindow?.rootViewController;
while ((tc!.presentedViewController) != nil) {
tc = tc!.presentedViewController;
}
return tc!;
}
特にありません
2021-05-14 14:21:41 | The pitfalls of Filetransfer in watchconnectivity on WatchOS. And how to avoid.
AppleWatch it succeeds with the actual machine, but if it is a simulator, it will fail、、、
When I... |
2021-05-06 14:04:37 | Line's animation stamp production pitfalls 、、、 failure story
I tried to make a LINE sticker during Golden Week.
I made it and applied, but it was different f... |
2021-04-22 14:54:53 | Cool carousel carefully selected 3 points! Astringent image slider using WebGL.
I was on a trip to find a cool slider yesterday.
It's simple, easy to use, and has a good de... |
Tweet
![]() |
|||
|