4. Instalação
Baixar do github (git clone git://github.com/uprise78/three20-P31.git)
Nas prefs do Xcode, incluir a pasta de src do Three20 como um “Source Tree”
Arrastar o Three20.xcodeproj para o root do seu projeto com o “Reference Type” relativo ao
Source Tree que você criou e SEM copiar.
Arrastar o libThree20.a para o link libraries do seu Target.
Configurar o Three20 como dependência do seu Target. Aproveitar e incluir o QuartzCore
framework ao Target.
Inclusão do bundle to Three20 no projeto, também sem copiar e relativo ao Source Tree.
Nas propriedades do projeto:
Incluir o Source Tree do Three20 no “Header Search Paths”
Incluir as flags “-ObjC” e “-all_load” no “Other Linker Flags”
Incluir o “Three20/Three20.h” nos seus headers.
5. Multifacetado!
Photo Browser
TTStyle Novos Widgets
Navegação interna
imitando web via Utilitários
“URLs”
7. Photo Browser
Three20 Photo Browsing System class
Data Interfaces protocol
The arrows indicate either the message(s) that a class sends *or* how it uses another class.
If a class implements a protocol, the protocol will be drawn inside the class's box.
scrollView:didMoveToPageAtIndex:
scollView:shouldZoom:
many other optional methods thumbsViewController:didSelectPhoto:
TTScrollView
TTScrollView Delegate
TTThumbs thumbsViewController:shouldNavigateToPhoto:
ViewController
TTScrollView
Delegate TTThumbsViewController
numberOfPagesInScrollView:
scrollView:pageAtIndex:
DataSource
scrollView:sizeOfPageAtIndex: tableView:objectForRowAtIndexPath:
many other optional methods load:nextPage:
TTPhotoViewController
list of "pages" TTTableView
displayed horizontally DataSource
TTThumbsDataSource
TTPhotoSource TTPhotoSource TTThumbsTableView
Delegate Delegate CellDelegate
TTPhotoView
TTPhotoView
TTPhotoView thumbsTableViewCell:didSelectPhoto:
TTThumbsTableViewCell
photoAtIndex: photoAtIndex:
each TTPhotoView asynchronously loadPhotosFromIndex:toIndex:cachePolicy:
photoSourceDidStartLoad loadPhotosFromIndex:toIndex:cachePolicy:
displays a single TTPhoto
photoSourceDidFinishLoad:
photoSource:didFailLoadWithError:
photoSourceDidCancelLoad:
TTPhoto TTPhotoSource
list of photos
Your TTPhoto Your TTPhotoSource
Implementation
Implementation
9. TTPhoto
Subclasse de TTPhoto
- (NSString*)URLForVersion:(TTPhotoVersion)version {
if (version == TTPhotoVersionLarge) {
return _URL;
} else if (version == TTPhotoVersionMedium) {
return _URL;
} else if (version == TTPhotoVersionSmall) {
return _smallURL;
} else if (version == TTPhotoVersionThumbnail) {
return _thumbURL;
} else {
return nil;
}
}
10. TTStyle
Inspirado no CSS do HTML
Catálogo do Look and Feel do seu app que pode mudar todo o look a
qualquer tempo
Sempre derivará do TTDefaultStyleSheet
[TTStyleSheet setGlobalStyleSheet:[[[MyStyleSheet alloc] init] autorelease]];
Repositórios de elementos globais como cores e fontes
Estilos complexos
12. Estilos complexos
É uma cadeia de TTStyle. Cada TTStyle é uma
“caixa preta” que pode desenhar ou
simplesmente alterar o contexto.
O Sample TTCatalog é o mais completo guia de
estilos.
TTStyle.h
TTStyleBuilder (http://github.com/klazuka/TTStyleBuilder)
15. TTStyledTextLabel
NSString* kText = @"
This is a test of styled labels. Styled labels support
<b>bold text</b>,
<i>italic text</i>,
<span class="blueText">colored text</span>,
<span class="largeText">font sizes</span>,
<span class="blueBox">spans with backgrounds</span>,
inline images
<img src="bundle://smiley.png"/>, and
<a href="http://www.google.com">hyperlinks</a> you can
actually touch. URLs are automatically converted into links, like this: http://www.foo.com
<div>You can enclose blocks within an HTML div.</div>
Both line break charactersnnand HTML line breaks<br/>are respected.";
TTStyledTextLabel* label1 = [[[TTStyledTextLabel alloc] initWithFrame:self.view.bounds] autorelease];
label1.font = [UIFont systemFontOfSize:17];
label1.text = [TTStyledText textFromXHTML:kText lineBreaks:YES URLs:YES];
label1.contentInset = UIEdgeInsetsMake(10, 10, 10, 10);
[label1 sizeToFit];
[self.view addSubview:label1];
30. 1 - Registrar as URLs
TTNavigator* navigator = [TTNavigator navigator];
navigator.persistenceMode = TTNavigatorPersistenceModeAll;
navigator.window = [[[UIWindow alloc] initWithFrame:TTScreenBounds()] autorelease];
TTURLMap* map = navigator.URLMap;
// Any URL that doesn't match will fall back on this one, and open in the web browser
[map from:@"*" toViewController:[TTWebController class]];
// The tab bar controller is shared, meaning there will only ever be one created. Loading
// This URL will make the existing tab bar controller appear if it was not visible.
[map from:@"tt://tabBar" toSharedViewController:[TabBarController class]];
// Menu controllers are also shared - we only create one to show in each tab, so opening
// these URLs will switch to the tab containing the menu
[map from:@"tt://menu/(initWithMenu:)" toSharedViewController:[MenuController class]];
// A new food controllers will be created each time you open a food URL
[map from:@"tt://food/(initWithFood:)" toViewController:[ContentController class]];
// This is an example of how to use a transition. Opening the nutrition page will do a flip
[map from:@"tt://food/(initWithNutrition:)/nutrition" toViewController:[ContentController class]
transition:UIViewAnimationTransitionFlipFromLeft];
31. 1 - Registrar as URLs
// The ordering controller will appear as a modal view controller, animated from bottom to top
[map from:@"tt://order?waitress=(initWithWaitress:)"
toModalViewController:[ContentController class]];
// This is a hash URL - it will simply invoke the method orderAction: on the order controller,
// and it will open the order controller first if it was not already visible
[map from:@"tt://order?waitress=()#(orderAction:)" toViewController:[ContentController class]];
// This will show the post controller to prompt to type in their order
[map from:@"tt://order/food" toViewController:[TTPostController class]];
// This will call the confirmOrder method on this app delegate and ask it to return a
// view controller to be opened. In this case, it will return an alert view controller.
// This kind of URL mapping gives you the chance to configure your controller before
// it is opened.
[map from:@"tt://order/confirm" toViewController:self selector:@selector(confirmOrder)];
// This will simply call the sendOrder method on this app delegate
[map from:@"tt://order/send" toObject:self selector:@selector(sendOrder)];
32. 2 - Criar Links p/ as URLs
Todo componente tem uma propriedade
URL = @”tt://order/food”
Em qualquer método:
TTOpenURL(@”tt://food/banana”);
Em Styled Text:
<a href=”tt://food/banana/nutrition”>Bananas!</a>
Em TTTableItems:
[TTTableTextItem itemWithText:@”Banana” URL:@”tt://food/banana”]