管理UIViews的最佳方法 - iPhone游戏

时间:2010-08-13 20:17:59

标签: iphone uiview ios4

我在这方面比较新......

在我的项目中,我有3个视图(源自UIView):

1)SplashView(游戏徽标和“播放”按钮)

2)SelectLevelView(1到20个不同级别的按钮)

3)GameView(在SelectLevelView中加载选定的级别)

使用代码(drawRect)编程所有视图。

SplashScreenView加载了这样的东西:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{    

    // Override point for customization after application launch.

    splashView = [[SplashView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];

    [window addSubview:splashView];
    [window makeKeyAndVisible];

    return YES;
}

在SplashView中,当触摸“播放”按钮时,我将SelectLevelView添加到它(使用[self addSubView:selectLevelView]),当我选择我要播放的de level时,我将GameView添加到SelectLevelView ...但是..我想这不是最好的方法。

那么......管理这种观点的最佳方法是什么?

使用UIViewController?但是......如何在GameView中访问它?

我不知道,我很困惑,此刻我的进步为零。

谢谢;)

1 个答案:

答案 0 :(得分:0)

你是什么意思

  

使用UIViewController?但是......如何在GameView中访问它?

为什么你不能在GameView中访问它?

只是为了确定:UIViewController是视图的包装器。简而言之,这里有UIViewController.h中的内容

UIViewController {
  UIView view;
}

- someUsefullFunctions ();
相关问题