TableViewSuite App 的项目类型是什么 [英] What kind of project type for TableViewSuite App

查看:18
本文介绍了TableViewSuite App 的项目类型是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从理论转向实践.我已经从 Apple 网站下载了几个示例代码.第一个应用程序是来自

I am moving from theory to some practice. I've downloaded from Apple site a couple of sample codes. The first app is TableViewSuite from

https://developer.apple.com/library/ios/#samplecode/TableViewSuite/Introduction/Intro.html

看起来不错,很有吸引力.我最喜欢的是以编程方式掌握 .nib 文件.我试图重复这个应用程序,但是亲爱的,选择什么样的项目?

Looks nice and attractive. The most thing I like is mastering .nib file programmatically. I tried to repeat this app, but oh Dear, what kind of project to choose?

  1. 基于导航的应用
  2. 基于视图的应用

  1. 基于窗口的应用程序?

首先我尝试了基于窗口的应用程序,因为它承诺

First I tried Window-Based Application cos it promises

此模板为任何应用程序提供了一个起点.它只提供一个应用程序委托和一个窗口.

This template provides a starting point for any application. It provides just an application delegate and a window.

听起来不错.只是窗口和委托,但是当我开始编写代码时,我遇到了这样的困境.在 Apple 的代码中,我必须实现的第一件事是用表视图公开 nib 文件是

Sounds good. Just window and delegate, but when I started to write code I've faced such dilemma. In Apple's code, the first thing I have to implement for exposing nib file with table view is

- (void)applicationDidFinishLaunching:(UIApplication *)application {

/*
 Create and configure the navigation and view controllers.
 */ 

RootViewController *rootViewController = [[RootViewController alloc] initWithStyle:UITableViewStylePlain];

// Retrieve the array of known time zone names, then sort the array and pass it to the root view controller.
NSArray *timeZones = [NSTimeZone knownTimeZoneNames];
rootViewController.timeZoneNames = [timeZones sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];

UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
self.navigationController = aNavigationController;
[aNavigationController release];
[rootViewController release];

// Configure and display the window.
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];

}

这个方法对我来说很清楚.我的意思是我很清楚它的作用.在我的应用中,此方法以完全不同的方式实现.

This method is clear for me. I mean it's clear for me what it does. In my app this method is implemented in quite different way.

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

它返回 BOOL 而不是返回 void 并且没有获取 (UIApplication *)application 参数,我无法使用样式初始化 RootViewController.

It returns BOOL instead of returning void and doesn't get (UIApplication *)application parameter and I can't initialize RootViewController with style.

那么,我应该选择什么样的项目?请帮助我提供您的建议.提前谢谢.

So, what kind of project should I choose? Please help me with your advice. Thanx in advance.

推荐答案

嘿 nathan 这两种方法的作用是一样的.如果您缺少 application 实例,那么您可以使用 [UIApplication sharedApplication] 创建它,因为这是一个单例,每次都会返回相同的实例.如果您是 iPhone 新手,那么首先选择基于视图,然后选择基于导航的应用程序,最后选择基于窗口的应用程序.
关于上面的两个方法
- (void)applicationDidFinishLaunching:(UIApplication *)application
方法在早期版本的iOS中用于初始化应用程序并准备运行.在 iOS 3.0 及更高版本中,您应该使用
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 代替.
这些是直接来自苹果文档的行,您可以查看 此处


这两种方法之间的区别在于,当您的应用程序由于本地/推送通知而启动时,方法 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 被调用并字典作为启动选项传递.所以用这个代替其他.

Hey nathan both these method does the same. And if you are missing application instance then you can create it using [UIApplication sharedApplication] as this is a singleton and will return the same instance every time. If you are new to iPhone then go for View Based first then go for Navigation based app and then finally for window based application.
And about the two method above
- (void)applicationDidFinishLaunching:(UIApplication *)application
method is used in earlier versions of iOS to initialize the application and prepare it to run. In iOS 3.0 and later, you should use the
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions instead.
These are the lines straight from apple's docs you can check here


The difference between these two method is that when your applicaion is launched due to local/push notification the the method - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions is called and a dictionary is passed as launch option. So use this one instead of other.


关于上面下载的代码,它是一个基于导航的应用程序.


And about the above downloaded code it is a navigation based application.

这篇关于TableViewSuite App 的项目类型是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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