Welcome to pickSourcecode.com Login | Register    
pickZy.com
 Home  | search  | games  | General  | C  | C++  | Java  | Php  | Networking  | Visual Basic  | VC++  | Win32  | MFC  | JavaScript  | Jobs  | JavaScript  | Post jobs
UiTable View       Share
2010-08-08 |  PackyaAmalan  | Viewed: 560  |    1

tableUitest2ViewController.h
---------------------------------------


#import <UIKit/UIKit.h>

@interface tableUitest2ViewController : UIViewController
{
    NSMutableArray *arr;
}

@end
----------------------------------------
tableUitest2ViewController.m
----------------------------------------

#import "tableUitest2ViewController.h"

@implementation tableUitest2ViewController

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    arr=[[NSMutableArray alloc] init];
    [arr addObject:@"Messi"];
    [arr addObject:@"Ronoldo"];
    [arr addObject:@"maradona"];
    [arr addObject:@"Ronaldinho"];
    [arr addObject:@"Federer"];
    [arr addObject:@"Nadal"];
    [arr addObject:@"Rey Mysterio"];
    [arr addObject:@"Cena"];
    [arr addObject:@"Dravid"];
    [arr addObject:@"Sachin"];
    [arr addObject:@"Woods"];
     
   
    [super viewDidLoad];
}


#pragma mark Table View Methods

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{      
    return 1; // number of sections
}

// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [arr count]; // number of rows
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{  
    // Sample statements
     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"tablecell"];
   
    cell=nil;
   
     if (!cell) {       
     cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"tablecell"] autorelease];  
     UILabel *name =[[UILabel alloc] initWithFrame:CGRectMake(10, 30 ,180 , 20)];
     [name setBackgroundColor:[UIColor clearColor]];
     name.text=[NSString stringWithFormat:@"Name  :  %@",[arr objectAtIndex:indexPath.row]] ;
     name.textAlignment =  UITextAlignmentLeft;
     name.textColor = [UIColor redColor];
     name.font = [UIFont systemFontOfSize:14];
     [cell addSubview:name];
         [name release];
     }
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)newIndexPath
{
   
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    return @"Players List"; // Table title
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 90.0; // table height
}

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
   
    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}

@end


Comments:





Submit comment's

Type:

User Comment's:

Submitted By:
Prof: Software Engineer
Tech: C ,Cpp
Send Mail: ratheesh



Related topics
UIView slide transition

Related References
iphone coding: slider tutorial

Web site contents © Copyright 2007, All rights reserved.
Help | Terms and Conditions | Privacy Policy | About Us