query: tag:InterfaceBuilder

どこが違うのか気になったのでメモ。
Window-based ApplicationをView-based Applicationと同じところまで持っていく作業を書き出してみます。

※ Xcode 4.1で動作確認しています。

###Window-based Applicationを作成

###RootViewControllerを作成
File - New - New FileでUIViewControllerテンプレートを選び、RootViewController(.h, .m, .xib)を作成する

###Interface Builderで作業
MainWindow.xibを開く
View - Utilities - Show Object Library を開いて、

  1. View ControllerをDrag & Drop

View - Utilities - Show Identity Inspector を開いて、

  1. 先にDropしたView Controllerを選択
  2. Custom ClassのClassをRootViewControllerに
  3. (LabelをRoot View Controllerに)

View - Utilities - Show Attributes Inspector を開いて、

  1. View ControllerのNIB NameをRootViewControllerに

View - Assistant Editor - Show Assistant Editor を開いて、

  1. AppDelegateクラス(h)を開く
  2. IB上でoptionキーを押しながらRoot View Controllerを選択、(hファイル上まで)DragしてInsert Outlet Connectionを追加(Name:viewController)

下記のようにコード生成されます:
rails>>
@interface RootViewControllerProtoAppDelegate : NSObject {
RootViewController *_viewController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet RootViewController *viewController;
<<--

###エディタでの作業
AppDelegateクラスのhで、@classを追加:
rails>>
@class RootViewController;
<<--

AppDelegateクラスのmで、#import、さらにself.viewControllerをself.window.rootViewControllerに
rails>>
#import "RootViewController.h"

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    // Override point for customization after application launch.
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    return YES;
    }
    <<--

厳密に言うと、View-based ApplicationではviewControllerの宣言のされ方が若干違います。そこは各自確認下さいませ。。
作業をしてみてIB経由でクラスにViewController変数を追加するのはやったことなかったので、とても勉強になりました :)

posted by satoko satoko on Tue 6 Sep 2011 at 15:33 with 0 comments
Contents rssrss
Leading Smart TV App Development Companies | USA | 4 Way Technologies
Apple TV Developer | TVOS Development | USA | 4 Way Technologies
光ファイバーを二次元振動させて走査するAR用ディスプレイ
因果の取り違え
Value Transformer
Swift2's defer for CoffeeScript
mongodb-3.0からcreateIndexのdropDupsが無くなったらしい
mongodb-3.0以降のWiredTigerの設定を動的に変更する方法
一般楕円の高速生成アルゴリズムへの道標
farro mantecatoのレシピ
Tags
InterfaceBuilder
Comments rssrss
https://dostavka-izkitaya5.ru/ https://dostavka-izkitaya5.ru/: Работаем с Китаем давно, растаможка — всегда самый... 04/18 23:17
https://rich-house.su/about/ https://rich-house.su/about/: улица Луначарского д https://rich-house.su/photos/... 04/18 22:41
https://tlc-alliance.ru/ https://tlc-alliance.ru/: Нам нужно привезти партию электроники из Шэньчжэ... 04/18 22:24
https://dostavka-izkitaya5.ru/ https://dostavka-izkitaya5.ru/: В 2026 году без нормальной растаможки на маркетпле... 04/18 21:47
https://rootskitchen.bar/ https://rootskitchen.bar/: Finished a deadly evening session punting on crash... 04/18 12:17
https://www.oyeanuncios.com/profile/margueritecava https://www.oyeanuncios.com/profile/margueritecava: Hat jemand Tipps gegen die leichte Übelkeit in der... 04/17 23:02
https://athworldproperties.com/author/deangelonewhou/ https://athworldproperties.com/author/deangelonewhou/: Mein Stoffwechsel fühlt sich zum ersten Mal seit J... 04/17 23:00
https://hyperharmony.com/author-profile/shannaminifie/ https://hyperharmony.com/author-profile/shannaminifie/: Endlich ist dieses ständige „Food Noise“ im Kopf k... 04/17 22:49