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
UITableVIew       Share
2010-07-13 |  pagadalaNaresh  | Viewed: 869  |    1

TableView Controller:


.m :

//
//    TableViewSample1ViewController.m
//    TableViewSample1
//
//    Created  by  training  on  7/13/10.
//    Copyright  __MyCompanyName__  2010.  All  rights  reserved.
//

#import "TableViewSample1ViewController.h"

@implementation TableViewSample1ViewController




/*
//  The  designated  initializer.  Override  to  perform  setup  that  is  required  before  the  view  is  loaded.
-  (id)initWithNibName:(NSString  *)nibNameOrNil  bundle:(NSBundle  *)nibBundleOrNil  {
       if  (self  =  [super  initWithNibName:nibNameOrNil  bundle:nibBundleOrNil])  {
             //  Custom  initialization
       }
       return  self;
}
*/


/*
//  Implement  loadView  to  create  a  view  hierarchy  programmatically,  without  using  a  nib.
-  (void)loadView  {
}
*/




//  Implement  viewDidLoad  to  do  additional  setup  after  loading  the  view,  typically  from  a  nib.
- (
void)viewDidLoad {
   ns = [[NSMutableArray alloc] init];

   NSInteger i;

   
for(i = 0; i < 20; i++)
   {

       [ns addObject : [NSString stringWithFormat: @"%d",i]];

   }

    [super viewDidLoad];

}




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

#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 [ns count]; 
//  number  of  rows
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{  

   
//  Sample  statements
   UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"tablecell"];

       

   
if (!cell) {          
       cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"tablecell"] autorelease];

#if 0
       UILabel *name;

       name =[[UILabel alloc] initWithFrame:CGRectMake(0, 0 ,185 , 20)];

       [name setBackgroundColor:[UIColor clearColor]];

       name.textAlignment =  UITextAlignmentLeft;

       name.textColor = [UIColor blueColor];

       name.font = [UIFont systemFontOfSize:14];

       [cell addSubview:name];

       [name release];

#endif        
   }

//        [cell  setText:[ns  objectAtIndex:indexPath.row]];
   cell.textLabel.text = [ns objectAtIndex:indexPath.row];

    return cell;

}


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


}


- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {

    return @"Trip History"; 
//  Table  title
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{

    return 40.0; 
//  table  height
}



- (
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 {
   [ns release];

    [super dealloc];

}


@end










Comments:





Submit comment's

Type:

User Comment's:

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



Related topics
Iphone Cocoa Programming tutorials
Iphone BubbleLevel Tutorials
Iphone UIImage Class Reference ( objective C )
Objective -C Date Formatter Examples -Iphone stringFromDate
iPhone Coding: Slider tutorial
Frequently used Iphone SDK API list

Related References
objective-c tutorial: nsarray -- arraywithcontentsofurl
iphone sdk: get contacts with the iphone sdk sample program
iphone sdk - local notification sample code (os 4.0 only)
resize uiimage sample tutorial

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