切换iphone应用程序的视图 - 这是正确的方法吗? [英] Switching views for iphone application - is this the right way?

查看:111
本文介绍了切换iphone应用程序的视图 - 这是正确的方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在寻找工作视图切换代码的​​许多小时后,我终于找到了一个很棒的教程在YouTube上。这正是我所需要的,因为我需要在按下按钮时切换视图。

After looking for many hours to find a working view switching code, I finally found a great tutorial on YouTube. It was exactly what I needed as I needed to switch views when buttons are pressed.

我只是想知道该视频中使用的技术是否有效。用于切换屏幕的代码是

I just wonder if the techniques used in that video are valid. The used code to switch screens is

viewsViewController *second = [[viewsViewController alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:second animated:YES];  

其中viewsViewController(或其中使用的任何类)是一个UIViewController的子类。这个类是通过单击File> New File> Add UIViewController subclass来生成的。

Where viewsViewController (or any class that is used there) is a class that's a subclass of UIViewController. This class is made by clicking File > New File > Add UIViewController subclass.

这个方法是否符合Apple指南?这种方法是否对内存友好?

Is this method according to the Apple guidelines? Is this method memory friendly?

我当然希望该技术有效。所有其他示例包含的信息太少,所以我无法使示例工作。这是非常时尚和简短的代码。

I sure hope the technique is valid. All other examples contained too little information so I couldn't make the example to work. And this is very stylish and short code which works .

推荐答案

这是一种方法。注意一些问题。两个视图都在内存中,如果它们的大小合适就可以了。模态视图在父级上方动画。

This is one way of doing it. Be aware of some issues. Both views will be in memory, which is okay if they are a reasonable size. The modal view animates above the parent.

如果这是您的主要目标,还可以使用其他模型进行简单导航。我建议看看UINavigationController,看看是否可以更好地满足您的需求。它可能是导航视图的最常用方法,并提供了很多视图管理的基础,为您节省了这些努力。

There are other models that you can use for simple navigation, if that's your main goal. I would suggest looking at UINavigationController and see if that might better meet your needs. It is probably the most common method to navigate views and provided a lot of the foundation of view management saving you that effort.

这篇关于切换iphone应用程序的视图 - 这是正确的方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆