LoginSignup
11
9

More than 5 years have passed since last update.

storyboard利用時に、カスタムUIWindowを使いたい場合

Last updated at Posted at 2015-01-21

アプリケーションが一定時間操作されていないことを検知したい場合などに、UIWindowのsendEventをフックしたいことがあると思います。

その場合、UIWindowを継承したクラスを作成すればよいのですが、storyboardを用いたテンプレートを利用していると、AppDelegateがUIWindowを見えないところで作っているので、カスタムUIWindowに置き換える方法がよくわかりません。

調査したところ、下記コードをAppDelegateに埋め込むと、UIWindowを作成時に自動で呼び出されるので、カスタムUIWindowに置き換わりました。

- (UIWindowCustom *)window
{
    static UIWindowCustom *customWindow = nil;
    if (!customWindow) customWindow = [[UIWindowCustom alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    return customWindow;
}
11
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
9