1

Hi I'm doing some objective-c projects and i'd like to know if there is a way to add a view from pushing a button. I don't come out of the blue, i first tried to make a project with a view controller and 2 views where i can switch between both of them by pushing button. The fact is i had already create my 2 views..it works so i guess i'm not so far from the solution but... Could anyone help me?

Thank you a lot.

4

1 に答える 1

2

ボタンを押したときにビューを追加する場合は、次を使用する必要があります。

UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
[self.view addSubview:view];

新しいビューコントローラーをプッシュしたい場合は、次を使用する必要があります。

UIViewController* vc = [[UIViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
于 2012-10-17T08:13:59.860 に答える