关于iPhone应用程序开发中的多个视图的问题

发布于 2024-11-17 02:41:42 字数 232 浏览 5 评论 0原文

是否可以创建一个可以处理 5 个视图的视图控制器? 是否可以在每个视图上实现不同的按钮以转换到根视图?

所以我对应用程序的想法是,当我加载它时,它会将我带到主窗口,在该窗口上将有 5 个按钮,将带我进入 5 个视图,在我进入该视图后,除其他按钮外,还会有只是一个按钮,只能将我带到主视图。

假设这 5 个视图中有一些是选项、分数、统计等。

如果可以使用如此多的视图制作这样的应用程序,这是一个好方法吗?

Is it possible to create a viewcontroller that could handle 5 views?
And is it possible to implement a different button on every view to make a transition to root view?

So my idea of the app is when I load it it takes me to main window, and on that window there will be 5 button that will take me to the 5 views, and after I'm in that view, among other buttons there will be just one button that will take me only to the MainView.

Let's say that some of those 5 views will be Options, Score, Statistics, something like that.

If it is possible to make an app like that using so much views, is it a good approach?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

锦欢 2024-11-24 02:41:42

这是可能的,但从你的描述来看,这听起来不是一个好主意。我建议改为制作一个选项卡栏应用程序,并为 5 个视图中的每一个视图都有一个单独的视图控制器。

如果您不想制作选项卡栏应用程序,您当然可以执行您所描述的操作,但我建议为每个视图都有一个单独的视图控制器实例。您可以在主视图中放置 5 个按钮,每个按钮都可以推送一个没有动画的模式视图。然后您可以添加任何您想要的过渡动画。在模态视图中,您可以有一个弹出模态视图的按钮。

在你的主视图控制器中,你可以这样做:

- (IBAction)button1Click {

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];

    UIViewController *newController = [[UIViewController alloc] initWithNibName:@"View1" bundle:nil];
    [self presentModalViewController:newController animated:NO];
    [newController release];

    [UIView commitAnimations];

}

在你的视图 1 控制器中:

- (IBAction)backToMainClick {

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];

    [self dismissModalViewControllerAnimated:NO];

    [UIView commitAnimations];

}

This would be possible, but from what you describe, it does not sound like a good idea. I would suggest instead making a Tab Bar app, and having a separate view controller for each of your 5 views.

If you do not want to make a tab bar app, you can certainly do what you describe, but I would recommend having a separate view controller instance for each view. You could have your 5 buttons in your main view, and each button could push a modal view with no animation. You could then add whatever transition animation you want. In your modal view, you could have a button that pops the modal view.

In your main view controller, you would do this:

- (IBAction)button1Click {

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];

    UIViewController *newController = [[UIViewController alloc] initWithNibName:@"View1" bundle:nil];
    [self presentModalViewController:newController animated:NO];
    [newController release];

    [UIView commitAnimations];

}

And in your view 1 controller:

- (IBAction)backToMainClick {

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];

    [self dismissModalViewControllerAnimated:NO];

    [UIView commitAnimations];

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文