简体   繁体   English

多视图iPhone应用程序-入门

[英]Multiple views iphone app - starter

Hello I am quite new in iphone programming and i am trying to create a new app with game elements 您好,我在iPhone编程方面还很陌生,我正在尝试使用游戏元素创建一个新应用

my problem is that i have a difficulty in undertanding delegates.. so in order to create multiple view this is what i have done i created a switchview method which is called every time a button is pressed in order to go to the next screen. 我的问题是我很难理解代表。.为了创建多个视图,这就是我要做的事情,我创建了一个switchview方法,每次按下按钮以转到下一个屏幕时都会调用该方法。

- (void)switchView:(UIView *)View1 toView:(UIView *)View2
{

[UIView beginAnimations:@"" context:nil];
[UIView setAnimationCurve:0.75];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.window cache:YES];
[window addSubview:View2];
[UIView commitAnimations];



}

My problem is that i want after the instruction to insert a viewController for video and then another one for finding and updating the location of the user.. 我的问题是我想在指令后插入视频的viewController,然后再插入一个用于查找和更新用户位置的视图控制器。

Do i have to insert handle every viewcontroller from the AppDelegate.m or is there another way?? 我必须从AppDelegate.m中插入每个ViewController的句柄,还是有其他方法?

eg the following code normally goes into the AppDelegate.m for the MediaPlayerViewController 例如,以下代码通常进入MediaPlayerViewController的AppDelegate.m中

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
MediaPlayerViewController *vc = [[MediaPlayerViewController alloc] init];
[[self window] setRootViewController:vc];
[vc release];

[self.window makeKeyAndVisible];
return YES;
}

how do i make it so after pressing the eg start button the next screen with the video player pops up?? 在按下“开始”按钮后,如何弹出视频播放器的下一个屏幕?

I am such a beginner it would be really helpful if smbd can answer.. 我是一个初学者,如果smbd可以回答,那将真的很有帮助。

Thanksss 谢谢

From your description and code snippets it looks like you have manually implemented a UINavigationController - and in the process created a lot of work for yourself. 根据您的描述和代码片段,您似乎已经手动实现了UINavigationController-在此过程中,您自己做了很多工作。

Apple provide the UINavigationContoller class as a core part of the UIKit framework for presenting users with a hierarchy of views. Apple提供UINavigationContoller类作为UIKit框架的核心部分,用于向用户提供视图层次结构。 This hierarchy is implemented using a stack data structure, where the stack is composed of a number of UIViewController instances. 此层次结构是使用堆栈数据结构实现的,其中堆栈由许多UIViewController实例组成。 The usage of a stack fits well with the navigation paradigm, as the user moves through the navigation hierarchy more views are pushed onto the stack. 堆栈的用法与导航范例非常吻合,因为用户在导航层次结构中移动时,更多视图被推到了堆栈上。 Take for example the Contacts app, its UINavigationController contains at first a UIViewController listing all contacts. 以Contacts应用程序为例,它的UINavigationController首先包含一个列出所有联系人的UIViewController。 Subsequently when a user taps on a contacts name they are presented with that contact's information. 随后,当用户点击联系人姓名时,他们会看到该联系人的信息。 This translates to a new UIViewController containing the contact's information being pushed onto the UINavigationController's stack. 这将转换为一个新的UIViewController,其中包含将联系人信息推送到UINavigationController堆栈中的信息。 Subsequently when the user moves back to the list of contacts they pop the contact information UIViewController from the stack. 随后,当用户移回联系人列表时,他们从堆栈中弹出联系人信息UIViewController。

The easiest way to see how this all works in practice is to create a new 'Navigation Based' project and look at the code. 在实践中了解这一切的最简单方法是创建一个新的“基于导航”的项目并查看代码。

I hope you might be knowing about inbuilt video player, you can make use of this to play video which can be presented as modal view: 我希望您可能对内置视频播放器有所了解,可以利用它来播放可以模态视图显示的视频:

MPMoviePlayerViewController *m_MoviePlayer =[[MPMoviePlayerViewController alloc] initWithContentURL:pUrl]; MPMoviePlayerViewController * m_MoviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:pUrl];

[self presentMoviePlayerViewControllerAnimated:m_MoviePlayer]; [self presentMoviePlayerViewControllerAnimated:m_MoviePlayer];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM