html5-img
1 / 47

Técnicas Avanzadas de Programación en iOS # iOSprogramacion

Técnicas Avanzadas de Programación en iOS # iOSprogramacion. mobile intelligence Software Engineering Lab. Agenda. Presentación del grupo PayPal Redes Sociales Personalizaci ón de tablas Generaci ón de Tiles. Agenda. Presentación del grupo PayPal Redes Sociales

weldon
Download Presentation

Técnicas Avanzadas de Programación en iOS # iOSprogramacion

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Técnicas Avanzadas de Programación en iOS#iOSprogramacion mobileintelligence Software EngineeringLab

  2. Agenda • Presentación del grupo • PayPal • Redes Sociales • Personalización de tablas • Generación de Tiles

  3. Agenda • Presentación del grupo • PayPal • Redes Sociales • Personalización de tablas • Generación de Tiles

  4. ¿Quiénes somos?

  5. ¿Qué hacemos? • Integración con mapas • Integración con pasarelas de pago • Integración con redes sociales

  6. ¿Qué hacemos? • Mapas

  7. ¿Qué hacemos? • Pasarelas de pago

  8. ¿Qué hacemos? • Redes Sociales

  9. Nosotros • José Ángel, Roberto, Adrián y Javier @Legasquare90 @roberes19 @jshcd @strikecr

  10. Agenda • Presentación del grupo • PayPal • Redes Sociales • Personalización de tablas • Generación de Tiles

  11. PayPal • Se puede incluir PayPal en diferentes plataformas móviles. • Ofrecen una versión Web y otra integra en la aplicación. • Ofrecen un entorno de pruebas.[1] • Antes de subir la App, ésta deberá pasar una revisión por parte de PayPal.

  12. PayPal (2) • Ofrecen códigos de ejemplo en diferentes lenguajes. [2] • SDKspara diferentes lenguajes. [3] • Librerías para iOS y Android. [3] • Ofrecen un asistente de integración que genera un código para la integración de Pago exprés. [4] • Otros asistentes de integración. [5]

  13. PayPal (3) Order2ViewController.m if (!tokenFetchAttempted) { tokenFetchAttempted= TRUE; reviewButton.enabled= FALSE; //Fetchthedevicereferencetokenimmediatelybeforedisplayingthe page containingthePaywith PayPal button. //Youmightdisplay a UIActivityIndicatorViewheretolettheuserknowsomethingisgoingon. [[PayPal getPayPalInst] fetchDeviceReferenceTokenWithAppID:@"APP-80W284485P519543T" forEnvironment:ENV_SANDBOXwithDelegate:self]; return; } reviewButton.enabled = TRUE;

  14. PayPal (4) Order2ViewController.m NSMutableString*buf = [NSMutableStringstringWithString:@"http://paydemo.sms4me.com/ECDemo-server/cart.jsp?"]; [bufappendFormat:@"delivery=%@", delivery.selectedSegmentIndex == 1 ? @"true" : @"false"]; [bufappendFormat:@"&count=%d", pizzaCount.selectedSegmentIndex + 1]; [bufappendString:@"&size="]; switch(size) { case SIZE_SMALL: [bufappendString:@"Small"]; break; case SIZE_MEDIUM: [bufappendString:@"Medium"]; break; case SIZE_LARGE: [bufappendString:@"Large"]; break; }

  15. PayPal (5) Order2ViewController.m if (toppingsArray.count > 0) { [bufappendFormat:@"&toppings=%@", [[toppingsArray objectAtIndex:0] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; for(int i = 1; i < toppingsArray.count; i++) { [bufappendFormat:@",%@", [[toppingsArrayobjectAtIndex:i] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; } } if (drt.length > 0) { [bufappendFormat:@"&drt=%@", drt]; }

  16. PayPal (6) Order2ViewController.m [self.navigationControllerpushViewController:[[[WebViewControlleralloc] initWithURL:bufendURL:@"http://paydemo.sms4me.com/ECDemo-server/cancel.html"] autorelease]animated:TRUE];

  17. Agenda • Presentación del grupo • PayPal • Redes Sociales • Personalización de tablas • Generación de Tiles

  18. Redes sociales (1/2) • 3 principales redes sociales en España: • Tuenti: No posee “zona de desarrollo”. • Facebook: Cantidad de herramientas para desarrollar. • http://developers.facebook.com • Twitter: Más sencillo, pero contiene todas las funcionalidades. • http://dev.twitter.com/ • Otras redes sociales

  19. Redes sociales (2/2) • 2 frameworks para iOS: • Twitter.h • Específico para Twitter y para iOS. • Problemas a partir de iOS 6.1 • Social.h • Combina mayor número de redes sociales: Twitter, Facebook y SinaWeibo. • Muy similar a Twitter.h

  20. Enviar un mensaje en Twitter Order2ViewController.h #import <Social/Social.h> … -(IBAction)twittear:(id)sender; Order2ViewController.m SLComposeViewController *tw = [SLComposeViewControllercomposeViewControllerForServiceType:SLServiceTypeTwitter]; if ([SLComposeViewControllerisAvailableForServiceType:SLServiceTypeTwitter]) { [twsetInitialText:mensaje]; [selfpresentModalViewController:twanimated:YES]; }

  21. Cargar vista de Timeline TwitterViewController.h #import <Social/Social.h> #import <Accounts/Accounts.h> TwitterViewController.m HUD = [[MBProgressHUDalloc] initWithView:self.navigationController.view]; [self.navigationController.viewaddSubview:HUD]; HUD.delegate = self; [MBProgressHUDshowHUDAddedTo:self.viewanimated:YES]; [selfcargarTweets];

  22. Timeline de Twitter (1/4) TwitterViewController.m NSURL *url = [NSURL URLWithString:@"http://api.twitter.com/1.1/search/tweets.json"]; NSString *terminoBusqueda = @"#PizzaExpress #iOSprogramacion"; ACAccountStore *accountStore = [[ACAccountStorealloc] init]; ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]; [accountStorerequestAccessToAccountsWithType:accountTypewithCompletionHandler:^(BOOL granted, NSError *error) { if (granted) { NSArray *accounts = [accountStoreaccountsWithAccountType:accountType]; if (accounts.count) { ACAccount *twitterAccount = [accounts objectAtIndex:0]; //Obtener datos } } }];

  23. Timeline de Twitter (2/4) TwitterViewController.m //Obtener datos NSMutableDictionary *parameters = [[NSMutableDictionaryalloc] init]; [parameterssetObject:terminoBusquedaforKey:@"q"]; //Busqueda [parameterssetObject:@"50" forKey:@"count"]; [parameterssetObject:@"0" forKey:@"include_entities"]; SLRequest *request = [SLRequestrequestForServiceType:SLServiceTypeTwitterrequestMethod:SLRequestMethodGET URL:url parameters:parameters]; [requestsetAccount:twitterAccount]; [requestperformRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { if (responseData) { //Tratar datos } }];

  24. Timeline de Twitter (3/4) TwitterViewController.m //Tratar datos NSError *error = nil; NSDictionary *dict = [NSJSONSerializationJSONObjectWithData:responseDataoptions:NSJSONReadingMutableLeaves error:&error]; if (dict) { NSMutableArray *dataSource = [dictmutableArrayValueForKey:@"statuses"]; for (int i=0; i<dataSource.count; i++){ NSDictionary *tweet = dataSource[i]; [namesaddObject:[[tweetobjectForKey:@"user"] objectForKey:@"name"]]; [messagesaddObject:[tweetobjectForKey:@"text"]]; NSURL *imageURL = [NSURL URLWithString:[[tweetobjectForKey:@"user"] objectForKey:@"profile_image_url"]]; NSData *imageData = [NSDatadataWithContentsOfURL:imageURL]; [photosaddObject:[UIImageimageWithData:imageData]]; } } //Recargar datos

  25. Timeline de Twitter (4/4) TwitterViewController.m [MBProgressHUDhideHUDForView:self.viewanimated:YES]; [HUD removeFromSuperview]; [HUD release]; HUD = nil; [tweetsreloadData]; cell.textLabel.text = names [indexPath.row]; cell.detailTextLabel.font = [UIFontfontWithName:@"Helvetica" size:12.0]; cell.detailTextLabel.lineBreakMode = NSLineBreakByWordWrapping; cell.detailTextLabel.numberOfLines = 4; cell.detailTextLabel.text = messages [indexPath.row]; cell.imageView.image = photos [indexPath.row];

  26. Agenda • Presentación del grupo • PayPal • Redes Sociales • Personalización de tablas • Generación de Tiles

  27. Personalización de tablas (1/14) • Clase -> UITableViewController • Protocolos -> UITableViewDataSource • Modelo <- - -> Vista -> UITableViewDelegate • Comportamiento y Apariencia de la vista

  28. Personalización de tablas (2/14) ListaLugaresViewController.h @interface ListaLocalesViewController : UIViewController<UITableViewDataSource, UITableViewDelegate>{ IBOutletUITableView *tablaLocales; NSMutableArray *listadoLocales; NSMutableArray *listadoDirecciones; }

  29. Personalización de tablas (3/14) • Tipos de tablas Plain Grouped

  30. Personalización de tablas (4/14) ListaLugaresViewController.m -> Personalización de encabezados de sección // Personalizar el encabezado de cada seccion - (UIView *) tableView:(UITableView *)tableViewviewForHeaderInSection:(NSInteger)section { }

  31. Personalización de tablas (5/14) ListaLugaresViewController.m -> Personalización de encabezados de sección // Crea la vista de cada seccion CGRectreferenceRect = CGRectMake(0, 0, tableView.bounds.size.width, 25); UIView *headerView = [[UIViewalloc] initWithFrame:referenceRect]; [headerViewsetBackgroundColor:[[UIColor colorWithRed:6.0/255.0 green:24.0/255.0 blue:188.0/255.0 alpha:1.0] initWithHue:0.0 saturation:0.0 brightness:1.0 alpha:1.0]]; headerView.opaque = NO;

  32. Personalización de tablas (6/14) ListaLugaresViewController.m -> Personalización de encabezados de sección // Crea el contenido de la vista UILabel *sectionTitle = [[UILabelalloc] initWithFrame:referenceRect]; [sectionTitlesetBackgroundColor:[UIColor colorWithRed:6.0/255.0 green:24.0/255.0 blue:188.0/255.0 alpha:1.0]]; sectionTitle.opaque = NO; sectionTitle.textColor = [UIColorwhiteColor]; sectionTitle.text = @" Locales Cercanos"; // Añade el contenido a la vista [headerViewaddSubview:sectionTitle]; returnheaderView;

  33. Personalización de tablas (7/14) ListaLugaresViewController.m -> DisclosureButton if (cell == nil) { cell = [[UITableViewCellalloc] initWithStyle:UITableViewCellStyleSubtitlereuseIdentifier:CellIdentifier]; cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; [cell.imageViewinitWithFrame:CGRectMake(0, 0, 54, 72)]; }

  34. Personalización de tablas (8/14) ListaLugaresViewController.m -> Imagen en una celda // Imagen del local UIImage *logoLocal; NSString *nombreLogoLocal; switch (indexPath.row) { case 0: nombreLogoLocal = @"dicarlo.png"; break; case 1: nombreLogoLocal = @"telepizza.png"; break;

  35. Personalización de tablas (9/14) ListaLugaresViewController.m -> Imagen en una celda case 3: nombreLogoLocal = @"pizzitas.png"; break; case 4: nombreLogoLocal = @"cafeteriaPequeña.png"; break; default: break; }

  36. Personalización de tablas (10/14) ListaLugaresViewController.m -> Imagen en una celda logoLocal = [UIImageimageNamed:nombreLogoLocal]; UIImage *iconoLogoLocal = [UIImageimageWithCGImage:[logoLocalCGImage] scale:0 orientation:0]; cell.imageView.image = iconoLogoLocal;

  37. Personalización de tablas (11/14) ListaLugaresViewController.m -> Alto de fila - (CGFloat)tableView:(UITableView *)tableViewheightForRowAtIndexPath:(NSIndexPath *)indexPath { return tableView.rowHeight + 40; }

  38. Personalización de tablas (12/14) ListaLugaresViewController.m -> Acción a realizar en tap sobre disclosurebutton - (void)tableView:(UITableView *)tableViewaccessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath{ NSString *appURL = @"http://maps.google.com/maps?q="; appURL = [appURLstringByAppendingFormat:[self.listadoDireccionesobjectAtIndex:indexPath.row]]; [tableViewdeselectRowAtIndexPath:indexPathanimated:YES]; [self openInSafari:appURL]; }

  39. Personalización de tablas (13/14) • URL Scheme -> permite lanzar una app desde otra app • Hay que definir un scheme en la app que se va a lanzar • La app que se va a lanzar captura el Scheme y realiza las acciones convenientes: - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url

  40. Personalización de tablas (14/14) ListaLugaresViewController.m -> Uso de URL Scheme NSString *appURL = @"uc3mmapas://place/1/"; appURL = [appURLstringByAppendingFormat:[self.listadoDireccionesobjectAtIndex:indexPath.row]]; [tableViewdeselectRowAtIndexPath:indexPathanimated:YES]; [self openInSafari:appURL];

  41. Agenda • Presentación del grupo • PayPal • Redes Sociales • Personalización de tablas • Generación de Tiles

  42. Generación de tiles (1/4) • ¿Qué son los tiles? • (del inglés) azulejos. • cada una de las imágenes que conforman un plano estándar como los de Google Maps, YahooMaps, Microsoft VirtualEarth u OpenStreeMap. • ¿Cómo se generan? • Editor gráfico (p.e. Photoshop). • GDAL - Geospatial Data Abstraction Library. • MapTiler (versión BETA que no funcionani en Mac OSX Lion ni Mountain Lion).

  43. Generación de tiles (2/4) • Editor gráfico • Utilizamos alguno en el que se puedan utilizar capas y dibujamos la imagen que queramos superponer. • Exportamos cada capa a un fichero TIFF diferente.

  44. Generación de tiles (3/4) • Convertimos los ficheros TIFF a formato VRT con GDAL • Es el paso intermedio antes de general los tiles con MapTiler. • Se necesitan al menos 3 puntos (recomendable 4). • En naranja, las coordenadas en pixeles y en azul, las coordenadas geoespaciales. En rojo el fichero de entrada y en verde el fichero de salida. gdal_translate -of VRT -a_srs EPSG:4326 -gcp8 536 -3.795605 40.312847-gcp128 52-3.785466 40.34441 -gcp635 10 -3.741574 40.347272 -gcp452 484 -3.75741 40.316185zona2.tifzona2.vrt

  45. Generación de tiles (4/4) • Generación automática de los tiles • Seleccionamos el tipo de conversión que queremos realizar. • Seleccionamos los niveles de zoom que queremos generar para mostrar en nuestra app.

  46. Bibliografía [1]https://cms.paypal.com/es/cgi-bin/?cmd=_render-content&content_ID=developer/howto_testing_sandbox [2]https://cms.paypal.com/es/cgi-bin/?cmd=_render-content&content_ID=developer/library_code [3]https://www.x.com/developers/paypal/documentation-tools/paypal-sdk-index [4] https://www.paypal-labs.com/integrationwizard/ecpaypal/main.php [5] https://www.paypal-labs.com/integrationwizard/index.php

  47. Técnicas Avanzadas de Programación en iOS#iOSprogramacion mobileintelligence Software EngineeringLab

More Related