0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

iPadOS 26 ウインドウ表示でのアプリ最小サイズの設定

Posted at

設定方法

UIWindowScene.sizeRestrictionsminimumSize に最小サイズを設定します。

SceneDelegate.swift
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
  var window: UIWindow?

  func scene(
    _ scene: UIScene,
    willConnectTo session: UISceneSession,
    options connectionOptions: UIScene.ConnectionOptions,
  ) {
    guard let windowScene = (scene as? UIWindowScene) else { return }

    // ここで最小サイズを設定
    windowScene.sizeRestrictions?.minimumSize = CGSize(width: 640, height: 640)
    ......
  }
}

ipad_size_restriction.gif

※ SwiftUI ベースの場合は windowResizability(_:) Modifier も利用できるはず

注意点

Dock 表示で高さが制限される

実際にはこのような値は設定しないとは思うのですが、 10000×10000pt のような明らかに無理な最小サイズは守られません。

ただ iPad の Dock 部分が高さを占有するため、現実的な問題として小型の iPad 端末の場合に想定していた最小サイズを確保できないというケースは発生しそうです。

dock.png

Split View / Slide Over 表示は制限できない

iPadOS 18 までの Split View / Slide Over では最小幅が 320pt となります。

これを回避するために

// iPhone SE 3rd サイズを保証
windowScene.sizeRestrictions?.minimumSize = CGSize(width: 375, height: 667)

としても、 Split View / Slide Over では横幅 320pt 表示を制限できません。

split_view.png

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?