Created
November 8, 2012 03:59
-
-
Save ChrisRisner/4036700 to your computer and use it in GitHub Desktop.
ios day 13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { | |
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"]; | |
NSDictionary *item =[itemsArray objectAtIndex:[indexPath row]]; | |
cell.textLabel.text = [item objectForKey:@"name"]; | |
return cell; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { | |
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"]; | |
NSDictionary *item =[itemsArray objectAtIndex:[indexPath row]]; | |
if ([indexPath row] < 12) | |
cell.textLabel.text = [item objectForKey:@"name"]; | |
return cell; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { | |
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"]; | |
NSDictionary *item =[itemsArray objectAtIndex:[indexPath row]]; | |
UILabel *labelOne = (UILabel *)[cell viewWithTag:1]; | |
UILabel *labelTwo = (UILabel *)[cell viewWithTag:2]; | |
labelOne.text = [item objectForKey:@"name"]; | |
labelTwo.text = [(NSNumber*)[item objectForKey:@"id"] stringValue]; | |
return cell; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { | |
NSLog(@"Row tapped at %i", [indexPath row]); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSArray *itemsArray; | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
// Do any additional setup after loading the view, typically from a nib. | |
NSDictionary *itemOne = @{ @"name" : @"item one", @"id" : @1}; | |
NSDictionary *itemTwo = @{ @"name" : @"item two", @"id" : @2}; | |
NSDictionary *itemThree = @{ @"name" : @"item three", @"id" : @3}; | |
NSDictionary *itemFour = @{ @"name" : @"item four", @"id" : @4}; | |
NSDictionary *itemFive = @{ @"name" : @"item five", @"id" : @5}; | |
NSDictionary *itemSix = @{ @"name" : @"item six", @"id" : @6}; | |
NSDictionary *itemSeven = @{ @"name" : @"item seven", @"id" : @7}; | |
NSDictionary *itemEight = @{ @"name" : @"item eight", @"id" : @8}; | |
NSDictionary *itemNine = @{ @"name" : @"item nine", @"id" : @9}; | |
NSDictionary *itemTen = @{ @"name" : @"item ten", @"id" : @10}; | |
NSDictionary *itemEleven = @{ @"name" : @"item eleven", @"id" : @11}; | |
NSDictionary *itemTwelve = @{ @"name" : @"item twelve", @"id" : @12}; | |
NSDictionary *itemThirteen = @{ @"name" : @"item thirteen", @"id" : @13}; | |
itemsArray = [[NSMutableArray alloc] initWithObjects:itemOne, itemTwo, | |
itemThree, itemFour, itemFive, itemSix, itemSeven, itemEight, | |
itemNine, itemTen, itemEleven, itemTwelve, itemThirteen, nil]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section | |
{ | |
return [itemsArray count]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView | |
{ | |
return 1; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@interface ViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment