English 中文(简体)
在 UIView 控制器内创建整个 UIView
原标题:Create entire UIView within UIViewController

我有一个UIView Control(控制器1),它正在UIView上显示一些UI纽扣。当点击一个按钮时,我愿意即刻启用第二个UIView Control(控制器2, 控制器2, 是一个完全不同的控制器类别), 它将在程序上创建一些 UIView View( 控制器1), 并将这些添加到由控制器1 管理的 UIIView 管理的一个界面中。

因此,在控制器1中,我喜欢以下代码:

- (void) someButtonPressed: (id)sender
{
    ViewController2* controller2 = [ [ ViewController2 alloc ] initWithNibName:nil bundle:nil ];
}

理想的情况是,在控制器1 (添加视图和类似的观点) 内,我将不再有任何进一步的代码行。 我真的要创建所有的观点,并将其添加到控制器2 代码内的现有观点中。

我试过把下面的代码输入控制器 2:

- (void)loadView
{

    NSLog(@"HPSViewEditorViewController loadView");

}

但它没有被调用。

我想将控制器2 整个UIView等级的控制器2 包含在控制器2 代码中,不要用除控制器2 即时化以外的任何东西来包罗控制器1 。

谢谢

最佳回答

我会尝试类似

[viewController1 presentModalViewController:viewController2 animated:YES];

这可以做这个把戏。 。 。

问题回答

UIVerenceles reference :

查看控制器在要求查看属性但目前为零时调用此方法。 此方法会装入或创建视图, 并将其分配到查看属性 。

- 在显示控制器2. View 被引用之前不会调用loadView 。





相关问题
Asynchronous request to the server from background thread

I ve got the problem when I tried to do asynchronous requests to server from background thread. I ve never got results of those requests. Simple example which shows the problem: @protocol ...

objective-c: Calling a void function from another controller

i have a void, like -(void) doSomething in a specific controller. i can call it in this controller via [self doSomething], but i don t know how to call this void from another .m file. I want to call ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

NSUndoManager and runModalForWindow:

I have a simple Core Data app which displays a list of entities in the main window. To create or add new entities, I use a second modal window with a separate managed object context so changes can be ...

NSMutableArray values becoming "invalid"

I m trying to show a database information in a tableview and then the detailed information in a view my problem is as follow: I created a NSMutableArray: NSMutableArray *myArray = [[NSMutableArray ...

iPhone numberpad with decimal point

I am writing an iPhone application which requires the user to enter several values that may contain a decimal point (currency values, percentages etc.). The number of decimal places in the values ...

热门标签