6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

シングルウィンドウ ライブラリスタイル アプリで左側表示領域サイズを固定する

Last updated at Posted at 2012-12-26

MacアプリでiPhotoやiTunesのような1ウィンドウ・ソースリスト(左側)・メイン表示(右側)という形式のアプリをAppleはSingle-window library-style appと呼んでいます。

そのようなウィンドウをデザインする場合、Vertical Split Viewというレイアウトビューを用いてレイアウトしますが、そのままではウィンドウリサイズ時に左側のビューサイズがウィンドウサイズに応じて変更されてしまいます。

左側のビューを固定サイズにしたい場合はNSSplitViewのデリゲート(ここではSplitViewDelegate.mとします)にてsplitView:shouldAdjustSizeOfSubviewを定義する必要があります。

SplitViewDelegate.m
/**
    Split View delegate method
    This keeps the source list on the left from resizing when the window is resized
 */
- (BOOL)splitView:(NSSplitView *)splitView shouldAdjustSizeOfSubview:(NSView *)subview {
    if (subview == [[splitView subviews] objectAtIndex:0]) return NO;
    else return YES;
}

参考URL:
Mac App Programming Guide: The Core App Design
NSSplitViewDelegate Protocol Reference

6
6
1

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
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?