Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // HomeViewController.m
- // UITableViewExample
- //
- // Created by Mani Shankar on 16/06/14.
- // Copyright (c) 2014 makemegeek. All rights reserved.
- //
- #import "HomeViewController.h"
- @interface HomeViewController ()
- @end
- @implementation HomeViewController
- @synthesize tableData,tableViewObject;
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
- {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- // Custom initialization
- }
- return self;
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- tableData = [[NSMutableArray alloc] initWithObjects:@"One",@"Two",@"Three",@"Four",@"Five",@"Six",@"Seven",@"Eight",@"Nine",@"Ten",nil];
- }
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- #pragma - markup TableView Delegate Methods
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return [tableData count];
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *simpleTableIdentifier = @"SimpleTableItem";
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
- if (cell == nil) {
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
- }
- cell.textLabel.text = [tableData objectAtIndex:indexPath.row];
- cell.imageView.image = [UIImage imageNamed:@"geekPic.jpg"];
- return cell;gtg
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Alert" message:[NSString stringWithFormat:@"Selected Value is
- %@",[tableData objectAtIndex:indexPath.row]] delegate:self cancelButtonTitle:@"Ok"
- otherButtonTitles:nil];
- [alertView show];
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement