将前一个工程,做修改。
//
// AppDelegate.h
// tableViewDemo
//
// Created by cloud on 13-3-28.
// Copyright (c) 2013年 cloud. All rights reserved.
//
#import <UIKit/UIKit.h>
@class ViewController;
@interface AppDelegate :UIResponder <UIApplicationDelegate>
@property (strong,nonatomic)UIWindow *window;
@property (strong,nonatomic)UINavigationController *viewController;
@end
修改appDlegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindowalloc]initWithFrame:[[UIScreenmainScreen]bounds]]autorelease];
// Override point for customization after application launch.
TableViewController *table=[[[TableViewControlleralloc]initWithStyle:UITableViewStylePlain]autorelease];
self.viewController = [[[UINavigationControlleralloc]initWithRootViewController:table]autorelease];
self.window.rootViewController =self.viewController;
[self.windowmakeKeyAndVisible];
return YES;
}
设置导航栏标题 TableViewController.m- (void)viewDidLoad
{
[superviewDidLoad];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
//self.tableView.rowHeight=80;
self.title=@"首页";
}
修改弹出子窗口- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create and push another view controller.
/*
<#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
*/
//UIAlertView *alert=[[[UIAlertView alloc] initWithTitle:@"选中了" message:[NSString stringWithFormat:@"你选中了第%d行",indexPath.row] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil] autorelease];
//[alert show];
NSString *str=[NSStringstringWithFormat:@"你选中了第%d节,第%d行",indexPath.section,indexPath.row];
ViewController *vc=[[[ViewControlleralloc]init] autorelease];
vc.title=@"第二页";
[self.navigationControllerpushViewController:vcanimated:YES];
vc.lblInfo.text=str;
}
源码地址http://download.csdn.net/detail/cloud95/5191487