Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Desenvolvimento iOS - Aula 4

1,114 views

Published on

Quarta aula do curso de iOS ministrado na DueCappa.

Published in: Technology, Art & Photos
  • Be the first to comment

  • Be the first to like this

Desenvolvimento iOS - Aula 4

  1. 1. Desenvolvimento deaplicativos mobile para iOS Aula 4 - Conhecendo alguns componentes
  2. 2. Componentes•UIImageView•UIScrollView•UIWebView
  3. 3. UIImageView • Mostrar uma imagem ou uma série animada de imagenshttp://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIImageView_Class/Reference/Reference.html
  4. 4. - (id)initWithImage:(UIImage *)image@property(nonatomic, retain) UIImage *image- (void)startAnimating- (void)stopAnimating@property(nonatomic) NSTimeInterval animationDuration@property(nonatomic, copy) NSArray *animationImages@property(nonatomic) NSInteger animationRepeatCount@property(nonatomic, getter=isHighlighted) BOOLhighlighted@property(nonatomic, retain) UIImage *highlightedImage
  5. 5. UIImage • Objeto de alto nível para exibir imagens • As instâncias são imutáveis • Provê várias formas de exibir imagenshttp://developer.apple.com/library/ios/#documentation/uikit/reference/UIImage_Class/Reference/Reference.html#//apple_ref/ occ/instm/UIImage/resizableImageWithCapInsets:
  6. 6. + (UIImage *)imageNamed:(NSString *)name+ (UIImage *)imageWithContentsOfFile:(NSString *)path+ (UIImage *)imageWithData:(NSData *)data+ (UIImage *)animatedImageWithImages:(NSArray *)imagesduration:(NSTimeInterval)duration- (UIImage *)resizableImageWithCapInsets:(UIEdgeInsets)capInsets
  7. 7. Convenção de nomes• Padrão: <ImageName><device_modifier>.<filename_extension>• Alta resolução: <ImageName>@2x<device_modifier>.<filename_extension>• Exemplos: Button.png, Button~ipad.png, Button@2x~ipad.png, Button@2x~iphone.png [UIImage:imageNamed:@"Button"]
  8. 8. Demo
  9. 9. UIScrollView • Provê suporte para exibir conteúdos que são maiores que a área de exibição da tela • Permite ao usuário rolar a tela usando “Swiping Gestures” e dar zoom usando “Pinching Gestures”http://developer.apple.com/library/ios/#DOCUMENTATION/WindowsViews/Conceptual/UIScrollView_pg/Introduction/ Introduction.html#//apple_ref/doc/uid/TP40008179-CH1-SW1
  10. 10. scrollView.contentSize = CGSizeMake(1920, 1080);
  11. 11. - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return self.imageView;}
  12. 12. Demo
  13. 13. UIWebView • Componente para embutir conteúdo da web no aplicativo • Por padrão, um web view converte números de telefone para linkshttp://developer.apple.com/library/ios/#documentation/uikit/reference/UIWebView_Class/Reference/Reference.html
  14. 14. - (void)loadRequest:(NSURLRequest *)request- (void)loadHTMLString:(NSString *)string baseURL:(NSURL*)baseURL@property(nonatomic, assign) id<UIWebViewDelegate>delegate- (void)stopLoading- (void)reload- (void)goBack- (void)goForward- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script
  15. 15. UIWebViewDelegate - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType: (UIWebViewNavigationType)navigationType- (void)webViewDidStartLoad:(UIWebView *)webView- (void)webViewDidFinishLoad:(UIWebView *)webView- (void)webView:(UIWebView *)webViewdidFailLoadWithError:(NSError *)error
  16. 16. Usando...- (BOOL)textFieldShouldReturn:(UITextField *)textField{ NSURLRequest* request = [NSURLRequest requestWithURL: [NSURL URLWithString:textField.text]]; [self.webView loadRequest:request]; [textField resignFirstResponder]; return YES;}
  17. 17. Demo

×