Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- return 1;
- #define kTagMyLabel 1
- - (UITableViewCell *)tableView:(UITableView *)tableView
- cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *cellID = @"Cell1";
- UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellID];
- UILabel * l;
- if (cell == nil) {
- // create the cell
- cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:cellID] autorelease];
- // perform setup/functions that are common to all cells
- l = [[[UILabel alloc] initWithFrame:CGRectMake(10,10,300,16)] autorelease];
- l.font=[UIFont boldSystemFontOfSize:15];
- l.textColor=[UIColor whiteColor];
- l.backgroundColor=[UIColor blackColor];
- l.tag = kTagMyLabel ;
- [cell.contentView addSubview:l];
- }
- else
- {
- // find the label we previously added.
- l = (UILabel*)[cell viewWithTag:kTagMyLabel];
- }
- // now set up the cell specific to this indexPath
- l.text=@"Just some random text here";
- return cell;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return 40;
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- return 100;
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- static NSString *cellID = @"Cell";
- [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
- UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellID];
- if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:cellID] autorelease];
- }
- UILabel *l=[[UILabel alloc] initWithFrame:CGRectMake(10,10,300,16)];
- l.font=[UIFont boldSystemFontOfSize:15];
- l.textColor=[UIColor whiteColor];
- l.backgroundColor=[UIColor blackColor];
- l.text=@"Just some randoom text here";
- [cell.contentView addSubview:l];
- [l release];
- return cell;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- static NSString *cellID = @"Cell";
- [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
- UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellID];
- if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:cellID] autorelease];
- UILabel *l=[[UILabel alloc] initWithFrame:CGRectMake(10,10,300,16)];
- l.font=[UIFont boldSystemFontOfSize:15];
- l.textColor=[UIColor whiteColor];
- l.backgroundColor=[UIColor blackColor];
- l.text=@"Just some randoom text here";
- [cell.contentView addSubview:l];
- [l release];
- }
- return cell;
- }
Add Comment
Please, Sign In to add comment