Three20是一些提供不同特性的独立模块(module)的组合。每个模块都是一个库(library),可以在我们的应用中引用。除了官方提供的模块,three20社区中有很多扩展(extension),由社区成员创作。
1)有关three20中的debug:
Three20中包含了代替NSLog语句的几个宏,带有不同的优先级。并可设置一个优先级阈值,只有大于等于此阈值的宏会打印出结果。也许这样能减少在茫茫字符串中寻找有用信息的痛苦。
C语言中的assert(断言)通常用来在debug中检查参数值,通常放在函数体开头。three200中定义了TTDASSERT宏实现类似的功能,但略有不同,详见文档。
2)有关three20中的导航:
如果在应用显示一个新的controller,传统的做法是初始化一个controller,然后将其push到NavigationController中:
RestaurantController* controller = [[RestaurantController alloc]
initWithName:@"Chotchkie's"];
[navigationController pushViewController:controller animated:YES];
[controller release];
Three20认为这样的做法不够简洁,代之以:
[navigator openURLAction:[TTURLAction actionWithURLPath:@"http://github.com/jverkoey"]];
[[TTNavigator navigator] openURLAction:
[[TTURLAction actionWithURLPath:@"tt://restaurant/Chotchkie's"] applyAnimated:YES]]
两者在功能上是等价的,最大的不同是思维方式。
如果你有一种不同于常规的思维,想让大家接受它,那这种思维方式必须具备常规思维所没有的优点。不妨imagine,URL的思维方式能带来什么优点?以下留白。。。
原文摘录:One huge advantage of using TTNavigator is the fact that the user's entire navigation state can be persisted automatically based on these URLs.
我猜测这是否意味着这个类会自动保存视图的当前状态到disk,来应对memory warning。由于国情的原因,我没Google到答案。
具体用法,原文摘录:
The first form is when you have a url, say "tt://menu/1", and this is being mapped to a Controller. Let's say we have the following map (from TTNavigatorDemo):
[map from:@"tt://menu/(initWithMenu:)"
toSharedViewController:[MenuController class]];
Opening "tt://menu/1" will call
[[MenuController alloc] initWithMenu:1]
This extends for multiple parameters, also. Let's say we want to display a specific page in MenuController.
[map from:@"tt://menu/(initWithMenu:)/(page:)"
toSharedViewController:[MenuController class]];
Opening "tt://menu/1/5" will call
[[MenuController alloc] initWithMenu:1 page:5]
当然不只以上两个特性,three20还包括很多已经做好的UI:http://three20.info/gallery
综上所述,我认为three20为我们做了很多事情,是值得去学习的。我们将有更多的时间去做更有意义的事。0daybank
文章评论