如何切换视图
我知道以前已经以不同的方式回答过这个问题,但我是一名新手程序员,确实需要一些上下文帮助。我有一个基本应用程序,它有多个视图控制器(每个都是.h、.m、.xib。EX.about.h、about.m、about.xib、options.h、options.m 等)。我需要按一下按钮在它们之间切换。
我一直在使用:
xxxViewController *titleScreen = [[xxxViewController alloc] initWithNibName:@"xxxViewController" bundle:[NSBundle mainBundle]];
[self.view addSubview:titleScreen.view];
[xxxViewController release];
并且切换视图效果很好。但后来我注意到,在仪器中,整体/净字节不断攀升,而没有“释放”它来自的视图。
我做错了什么吗?请帮助...我很绝望!
I know this has been answered before in different ways, but I am a novice programmer and really need some contextual help. I have a basic application that has multiple view controllers (.h, .m, .xib each. EX. about.h, about.m, about.xib, options.h, options.m, etc.). I need to switch between them on the press of a button.
I had been using:
xxxViewController *titleScreen = [[xxxViewController alloc] initWithNibName:@"xxxViewController" bundle:[NSBundle mainBundle]];
[self.view addSubview:titleScreen.view];
[xxxViewController release];
and it worked fine to switch the views. But then I noticed that in Instruments, the overall/net bytes kept climbing, without "releasing" the view that it came from.
Am I doing something wrong? Please help... I'm desperate!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您并没有切换视图,您只是以这种方式将一个视图添加到另一个视图之上。如果您想在不同的视图之间导航,您可能需要 导航控制器。
You aren't switching views, you're just just adding one on top of the other that way. If you want to navigate between different views, chances are, you want a navigation controller.