Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save FabiolaRamirez/a8e12edbf723d43a4c8d to your computer and use it in GitHub Desktop.
Save FabiolaRamirez/a8e12edbf723d43a4c8d to your computer and use it in GitHub Desktop.
//
// InformationPlaceTableViewController.m
// Proyecto2
//
// Created by Fabiola Ramirez on 27/08/14.
// Copyright (c) 2014 Fabiola Ramirez. All rights reserved.
//
#import "InformacionCell.h"
#import "OneInformationTableViewCell.h"
#import "InformationPlaceTableViewController.h"
@interface InformationPlaceTableViewController (){
NSMutableArray *sectionArray;
NSMutableArray *rowInSectionArray;
}
@end
@implementation InformationPlaceTableViewController
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
//instanciando sectionArray para las secciones
sectionArray=[[NSMutableArray alloc] init];
rowInSectionArray=[[NSMutableArray alloc] initWithObjects:@"holes",@"hi", nil];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
NSString *title;
if (section == 0){
return title=@"Static Cells";
}
if (section == 1){
return title=@"Dynamic Cells";
}
return title;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == 0) {
return 1; //However many static cells you want
} else {
return [rowInSectionArray count];
}}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
if(indexPath.row==0){
//primera forma:
/*OneInformationTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"oneStaticCell"];
if(cell == nil){
me sale error en este inicializacion de la celda:
cell = [[OneInformationTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"oneStaticCell"];
}
cell.title.text = @"addressñññññññ";
NSLog(@"ENTRA CELL STATIC!!!");
return cell;*/
//segunda forma:
//***antes corria con esta, pero despues ya no :(
/*InformacionCell *cell = [tableView dequeueReusableCellWithIdentifier:@"informacionCell"];
if(cell == nil){
cell = [InformacionCell informacionCell];
cell.informacionLabel.text=@"hello everybody";
}
return cell;
*/
//tercera forma:
/*OneInformationTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"oneInformationTableViewCell"];
if(cell == nil){
me sale error en este inicializacion de la celda:
NSString *cellIdentifier=@"oneInformationTableViewCell";
cell = [[OneInformationTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
cell.title.text=@"hello everybody";
return cell;*/
}
} else if(indexPath.section == 1){
NSString *cellIdentifier = @"dynamicCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
cell.textLabel.text = [rowInSectionArray objectAtIndex:indexPath.row];
NSLog(@"entra cell dinamica!!");
return cell;
}
return nil;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if(indexPath.section==0){
/* if (indexPath.row == 0) {
return 44;
} else if(indexPath.row==1){
return 88;
} else if(indexPath.row==2){
return 44;
}*/
return 44;
}
if(indexPath.section==1){
return 88;
}
return 100.0f; //cell for comments, in reality the height has to be adjustable
}
/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the specified item to be editable.
return YES;
}
*/
/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
} else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/
/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the item to be re-orderable.
return YES;
}
*/
/*
#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.
}
*/
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment