Download Demo From Hear.....
--------------------------------------------------------AppDelegate.h--------------------------------------------------
#import <UIKit/UIKit.h>
@class ViewController;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) ViewController *viewController;
@end
---------------------------------------------------------AppDelegate.m-------------------------------------------------
#import "AppDelegate.h"
#import "ViewController.h"
@implementation AppDelegate
@synthesize window = _window;
@synthesize viewController = _viewController;
- (void)dealloc
{
[_window release];
[_viewController release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
@end
----------------------------------------------------ViewController.xib----------------------------------------------------
in xib drag adn drop tableview in view
then give reffernce to it....
reference to delegate....also
----------------------------------------------------ViewController.h----------------------------------------------------
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
{
IBOutlet UITableView *tbl;
}
@property(nonatomic,retain) IBOutlet UITableView *tbl;
@end
--------------------------------------------------ViewController.m------------------------------------------------------
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
// Return how many rows in the table
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 10;
}
// Return a cell for the ith row
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// Use re-usable cells to minimize the memory load
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:nil];
//dequeueReusableCellWithIdentifier:nil is not overload the cell value
if (!cell) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:nil] autorelease];
//reuseIdentifier:nil is not overload the cell value both place must use....
}
// Set up the cell's text
cell.textLabel.text = [[UIFont familyNames] objectAtIndex:[indexPath row]];
// cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
//the above line show discloser button (arrow button) in all cell
// cell.hidesAccessoryWhenEditing = NO;
return cell;
}
@end
--------------------------------------------------------AppDelegate.h--------------------------------------------------
#import <UIKit/UIKit.h>
@class ViewController;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) ViewController *viewController;
@end
---------------------------------------------------------AppDelegate.m-------------------------------------------------
#import "AppDelegate.h"
#import "ViewController.h"
@implementation AppDelegate
@synthesize window = _window;
@synthesize viewController = _viewController;
- (void)dealloc
{
[_window release];
[_viewController release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
@end
----------------------------------------------------ViewController.xib----------------------------------------------------
in xib drag adn drop tableview in view
then give reffernce to it....
reference to delegate....also
----------------------------------------------------ViewController.h----------------------------------------------------
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
{
IBOutlet UITableView *tbl;
}
@property(nonatomic,retain) IBOutlet UITableView *tbl;
@end
--------------------------------------------------ViewController.m------------------------------------------------------
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
// Return how many rows in the table
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 10;
}
// Return a cell for the ith row
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// Use re-usable cells to minimize the memory load
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:nil];
//dequeueReusableCellWithIdentifier:nil is not overload the cell value
if (!cell) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:nil] autorelease];
//reuseIdentifier:nil is not overload the cell value both place must use....
}
// Set up the cell's text
cell.textLabel.text = [[UIFont familyNames] objectAtIndex:[indexPath row]];
// cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
//the above line show discloser button (arrow button) in all cell
// cell.hidesAccessoryWhenEditing = NO;
return cell;
}
@end
No comments:
Post a Comment