2009-02-24 12 views

答えて

2

はい可能です。ビューコントローラを使用して新しいビューを作成し、そのビューのインスタンスをクラスに作成するだけです。その後、ibactionでいくつか削除してサブビューを追加することができます。それはちょうど、迅速かつ簡単な方法カントーだ、あなたは

編集リクエストに応じてなど、あなたがそれぞれのビューを管理する方法をして、より多くの詳細に入ることができます:あなたのクラスで は、あなたがそれのインスタンスを作成しますそのようなインターフェイス:

MyClass *myClass; (make sure to alloc and init in the init or awakeFromNib method) 

次に、このようibactionでアプリデリゲートのインスタンスを作成:

MyAppDelegate *myAppDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate]; 

そして、あなたは別の観点から切り替えるには、この操作を行うことができます

[self removeFromSuperView]; (or self.view in case this is a view controller) 
[[myAppDelegate window] addSubview:myClass]; 
+0

感謝を。いくつかのサンプルコードまたはサンプルコードを私に渡すことができますか? – Nasir

1

あなたはプログラム的にビューを追加するには、次のような何かすることができます:ウル答えを

 //If you create controllers via XCode, just link them in the .h file with IBOutlet 
    UIViewController *aViewController = [[UIViewController alloc] initWithNibName:@"YourNibName" bundle:[NSBundle mainBundle]]; 
    self.viewController = aViewController; 
    [aViewController release]; 
    // Add the view controller's view as a subview of the window 
    UIView *controllersView = [viewController view]; 
    [window addSubview:controllersView]; 
    [window makeKeyAndVisible]; 
関連する問題