Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
9
Help us understand the problem. What is going on with this article?
@fuhi1983

画面切り替え(マルチタスク)画面でのアプリのサムネイルの切替

More than 5 years have passed since last update.

パスコードロックを使用しているアプリの多くはバックグラウンドにした後、
フォアグラウンドにするとパスコード入力画面を表示できます。

バックグラウンド中に画面切り替え(マルチタスク)画面を表示すると、
パスコード入力画面ではなく、バックグラウンドにする前に
表示していた画面が見えてしまうことがあります。
2.png

パスコード入力画面を表示する方法を試行錯誤しましたので投稿します。
あくまで画面切替画面でのサムネイルを変更することだけを記載しています。
フォアグラウンドにした際にパスコード入力させるようにするには、別途実装が必要です。

■準備
・パスコード入力画面のスクリーンショット
 ※ここでは passcode@2x.png を用意しました
passcode@2x.png

■実装
・AppDelegate.hとAppDelegate.mを少し変更
// add とした部分のみ

AppDelegate.h
#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;
@property (nonatomic) UIImageView *passcodeSplashView; // Add
@end
AppDelegate.m

#import "AppDelegate.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    _passcodeSplashView = [[UIImageView alloc]initWithFrame:self.window.bounds]; // Add
    _passcodeSplashView.image = [UIImage imageNamed:@"passcode.png"]; // Add

    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.

    [self.window addSubview:_passcodeSplashView]; // Add
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
    [_passcodeSplashView removeFromSuperview]; // Add
}


- (void)applicationDidEnterBackground:(UIApplication *)application
{
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.


}


- (void)applicationWillTerminate:(UIApplication *)application
{
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end

■結果
3.png

9
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
fuhi1983
プログラミング以外のネタ http://swift-studying.com/blog/news/

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
9
Help us understand the problem. What is going on with this article?