Skip to content

Instantly share code, notes, and snippets.

@FabiolaRamirez
Created August 30, 2014 02:13
Show Gist options
  • Save FabiolaRamirez/9ee2921d9dcf8571d48f to your computer and use it in GitHub Desktop.
Save FabiolaRamirez/9ee2921d9dcf8571d48f to your computer and use it in GitHub Desktop.
//
// Place2ViewController.m
// Proyecto2
//
// Created by Fabiola Ramirez on 07/08/14.
// Copyright (c) 2014 Fabiola Ramirez. All rights reserved.
//
#import "Place2ViewController.h"
#import "TipCell.h"
#import "MapCell.h"
#import "InformacionCell.h"
#import "ExtraCell.h"
#import "AccionesCell.h"
@interface Place2ViewController ()
@end
@implementation Place2ViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.locationDetail = [[TGFoursquareLocationDetail alloc] initWithFrame:self.view.bounds];
self.locationDetail.tableViewDataSource = self;
self.locationDetail.tableViewDelegate = self;
self.locationDetail.delegate = self;
self.locationDetail.parallaxScrollFactor = 0.3; // little slower than normal.
[self.view addSubview:self.locationDetail];
[self.navigationController setNavigationBarHidden:YES animated:YES];
[self.view bringSubviewToFront:_headerView];
UIButton *buttonBack = [UIButton buttonWithType:UIButtonTypeCustom];
buttonBack.frame = CGRectMake(10, 22, 44, 44);
[buttonBack setImage:[UIImage imageNamed:@"Back"] forState:UIControlStateNormal];
[buttonBack addTarget:self action:@selector(goBack:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:buttonBack];
UIButton *buttonPost = [UIButton buttonWithType:UIButtonTypeCustom];
buttonPost.frame = CGRectMake(self.view.bounds.size.width - 44, 18, 44, 44);
[buttonPost setImage:[UIImage imageNamed:@"btn_post"] forState:UIControlStateNormal];
[buttonPost addTarget:self action:@selector(post) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:buttonPost];
self.locationDetail.headerView = _headerView;
}
- (void)goBack:(id)sender {
NSLog(@"SE PRESIOONO IR ATRAS");
// SALID MODAL
// [self dismissViewControllerAnimated:YES completion:nil];
// SALIR PUSH
[self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 4;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 0) {
AccionesCell *cell = [tableView dequeueReusableCellWithIdentifier:@"accionesCell"];
if(cell == nil){
cell = [AccionesCell accionesCell];
}
return cell;
} else if (indexPath.row == 1) {
MapCell *cell = [tableView dequeueReusableCellWithIdentifier:@"mapCell"];
if(cell == nil){
cell = [MapCell mapCell];
//calculo de distancia desde mapa
cell.distanciaLabel.text = @"15";
//direccion almacenado en parse
cell.direccionLabel.text = self.lugar[@"address"];
NSLog(@"DIRECCION DEL LGAR %@", self.lugar[@"address"]);
}
return cell;
}else if(indexPath.row==2){
InformacionCell *cell = [tableView dequeueReusableCellWithIdentifier:@"informacionCell"];
if(cell == nil){
cell = [InformacionCell informacionCell];
cell.informacionLabel.text=self.lugar[@"introduction"];
}
return cell;
}
else if(indexPath.row==3){
ExtraCell *cell = [tableView dequeueReusableCellWithIdentifier:@"extraCell"];
if(cell == nil){
cell = [ExtraCell extraCell];
cell.contadorAmigosLabel.text=@"0";
cell.contadorPersonasLabel.text=@"0";
cell.ContadorCalificacionLabel.text=@"0,0";
}
return cell;
}
return nil;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row == 0) {
return 88;
} else if(indexPath.row==1){
return 88;
} else if(indexPath.row==2){
return 66;
} else if(indexPath.row==3){
return 88;
}
return 100.0f; //cell for comments, in reality the height has to be adjustable
}
#pragma mark - LocationDetailViewDelegate
- (void)locationDetail:(TGFoursquareLocationDetail *)locationDetail imagePagerDidLoad:(KIImagePager *)imagePager
{
imagePager.dataSource = self;
imagePager.delegate = self;
imagePager.pageControl.currentPageIndicatorTintColor = [UIColor lightGrayColor];
imagePager.pageControl.pageIndicatorTintColor = [UIColor blackColor];
imagePager.slideshowTimeInterval = 0.0f;
imagePager.slideshowShouldCallScrollToDelegate = YES;
self.locationDetail.nbImages = [self.locationDetail.imagePager.dataSource.arrayWithImages count];
self.locationDetail.currentImage = 0;
}
- (void)locationDetail:(TGFoursquareLocationDetail *)locationDetail tableViewDidLoad:(UITableView *)tableView
{
tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
}
- (void)locationDetail:(TGFoursquareLocationDetail *)locationDetail headerViewDidLoad:(UIView *)headerView
{
[headerView setAlpha:0.0];
[headerView setHidden:YES];
}
#pragma mark - KIImagePager DataSource
- (NSArray *) arrayWithImages
{
return @[
@"https://irs2.4sqi.net/img/general/500x500/2514_BvEN_Q6lG50xZQ9TIG0XY8eYXzF3USSMdtTmxHCmqnE.jpg",
@"https://irs3.4sqi.net/img/general/500x500/6555164_Rkk21OJj4X54X8bkutzxbeCwLHTA8Hrre6_wUVc1DMg.jpg",
@"https://irs2.4sqi.net/img/general/500x500/3648632_NVZOdXiRTkVtzHoGNh5c5SqsF2NxYDB_FMfXRCbYu6I.jpg",
@"https://irs1.4sqi.net/img/general/500x500/23351702_KoUKj6hZLOTHIsawxi2L64O5CpJwCadeIv2daMBDE8Q.jpg"
];
}
- (UIViewContentMode) contentModeForImage:(NSUInteger)image
{
return UIViewContentModeScaleAspectFill;
}
- (NSString *) captionForImageAtIndex:(NSUInteger)index
{
return @[
@"First screenshot",
@"Another screenshot",
@"Last one! ;-)"
][index];
}
#pragma mark - KIImagePager Delegate
- (void) imagePager:(KIImagePager *)imagePager didScrollToIndex:(NSUInteger)index
{
NSLog(@"se movio");
}
- (void) imagePager:(KIImagePager *)imagePager didSelectImageAtIndex:(NSUInteger)index
{
NSLog(@"se presiono");
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment