I have created a personalized list with code, I need that according to the selection so be the view that opens me, I do not know anything about this, I'm starting. I hope you can give me some help!
ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UITableViewDataSource,UITableViewDelegate>
@property (copy,nonatomic) NSArray *greekLetters;
@end
ViewController.m
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.greekLetters = @[@"Himnario",@"Informacion"];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger) tableView:(UITableView *) tableView numberOfRowsInSection:(NSInteger)section{
return [self.greekLetters count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *SimpleIdentifier = @"SimpleIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleIdentifier];
if(cell == nil){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:SimpleIdentifier];
}
UIImage *image1 = [UIImage imageNamed:@"himnario.png"];
UIImage *image2 = [UIImage imageNamed:@"informacion.png"];
cell.textLabel.text = self.greekLetters[indexPath.row];
//cell.textLabel.font = [UIFont boldSystemFontOfSize:10];
//ESTO ES EL TAMA;O DE LA FUENTE DE TEXTO
if (indexPath.row==0) {
cell.detailTextLabel.text = @"Lista de himnos";
cell.imageView.image= image1;
}
if (indexPath.row==1) {
cell.detailTextLabel.text = @"Sobre el desarrollador";
cell.imageView.image= image2;
}
return cell;
}
//ESTO SOLO ES PARA PROBAR CUANDO SELECCIONO ALGO DE ESTA LISTA
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *rowValue = self.greekLetters[indexPath.row];
NSString *message = [[NSString alloc] initWithFormat:@"Ha seleccionado: %@!",rowValue];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Item Seleccionado: " message:message delegate:nil cancelButtonTitle:@"Aceptar" otherButtonTitles:nil, nil];
[alert show];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
//ESTO ES EL ANCHO DE LOS ITEMS
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 50;
}
@end