啥是分割试图,废话不说先上个图吧

      ipad上的mail程序左侧邮件列表右侧显示邮件内容

横屏显示时列表与详情页分割显示

竖屏显示时详情页占满全屏列表做为弹出层

图看完了,开始动手

打开Xcode FileNew 》New Project.新建一个项目选择Master-Detail Application

 点击next

 

名字Presidents,   Class Prefix = BID,Device Family = iPad. 勾选Use Storyboard 和 Use Automatic Reference Counting 取消 Use Storyboard , Use Core Data 和  Unit Tests 

点击next并运行 模拟器中的显示应该是这个样子

 

 

模拟器看完了我们回到Xcode单击MainStoryboard.storyboard看看这些视图是如何连接起来的

ios5后就引入了一个新东西 storeboasds来描述和展示不同UI之间的关系,如上图,视图之间的连线就代表视图间的关系,如此我们看起来方便也省代码,当然你点击那些线时还能在右边的属性检查器中编辑它们的属性。

接下来让我们看看Xcode为我们生成了什么代码

BIDAppDelegate.h    


  
  1. #import <UIKit/UIKit.h> 
  2. @interface BIDAppDelegate : UIResponder <UIApplicationDelegate> 
  3. @property (strong, nonatomic) UIWindow *window; 
  4. @end 

BIDAppDelegate.m   


  
  1. #import "BIDAppDelegate.h" @implementation BIDAppDelegate @synthesize window = _window; 
  2. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
  3. // Override point for customization after application launch. 
  4. UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
  5. UINavigationController *navigationController = [splitViewController.viewControllers lastObject]; 
  6. splitViewController.delegate = (id)navigationController.topViewController; 
  7. return YES; 
  8. }
  9.  @end 

在说这段代码的功能之前我们先来看看手册中关于UISplitViewController的viewControllers的介绍

 

这段文字的大致意思是viewControllers必须有两个视图控制器,在横屏显示时从左到右排列,索引为0的在左边

索引为1的在右边。在竖屏显示时候左边的视图默认是隐藏的,如果需要显示则需要指派一个delegate

让我们回头看看刚才那断代码主要,首先获得系统的UISplitViewController(rootViewController)然后把UISplitViewController的delegate设置为右边区域navigationController的topViewController

相关代码

 BIDAppDelegate.h 


  
  1. // 
  2. //  BIDAppDelegate.h 
  3. //  Presidents 
  4. // 
  5. //  Created by julian on 12-3-25. 
  6. //  Copyright (c) 2012年 __MyCompanyName__. All rights reserved. 
  7. // 
  8.  
  9. #import <UIKit/UIKit.h> 
  10.  
  11. @interface BIDAppDelegate : UIResponder <UIApplicationDelegate> 
  12.  
  13. @property (strong, nonatomic) UIWindow *window; 
  14.  
  15. @end 

BIDAppDelegate.m 


  
  1. // 
  2. //  BIDAppDelegate.m 
  3. //  Presidents 
  4. // 
  5. //  Created by julian on 12-3-25. 
  6. //  Copyright (c) 2012年 __MyCompanyName__. All rights reserved. 
  7. // 
  8.  
  9. #import "BIDAppDelegate.h" 
  10.  
  11. @implementation BIDAppDelegate 
  12.  
  13. @synthesize window = _window; 
  14.  
  15. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
  16.     // Override point for customization after application launch. 
  17.     UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController; 
  18.     UINavigationController *navigationController = [splitViewController.viewControllers lastObject]; 
  19.     splitViewController.delegate = (id)navigationController.topViewController; 
  20.     return YES; 
  21.                              
  22. - (void)applicationWillResignActive:(UIApplication *)application 
  23.     /* 
  24.      Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 
  25.      Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 
  26.      */ 
  27.  
  28. - (void)applicationDidEnterBackground:(UIApplication *)application 
  29.     /* 
  30.      Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.  
  31.      If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 
  32.      */ 
  33.  
  34. - (void)applicationWillEnterForeground:(UIApplication *)application 
  35.     /* 
  36.      Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 
  37.      */ 
  38.  
  39. - (void)applicationDidBecomeActive:(UIApplication *)application 
  40.     /* 
  41.      Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 
  42.      */ 
  43.  
  44. - (void)applicationWillTerminate:(UIApplication *)application 
  45.     /* 
  46.      Called when the application is about to terminate. 
  47.      Save data if appropriate. 
  48.      See also applicationDidEnterBackground:. 
  49.      */ 
  50.  
  51. @end 

BIDMasterViewController.h 


  
  1. // 
  2. //  BIDMasterViewController.h 
  3. //  Presidents 
  4. // 
  5. //  Created by julian on 12-3-25. 
  6. //  Copyright (c) 2012年 __MyCompanyName__. All rights reserved. 
  7. // 
  8.  
  9. #import <UIKit/UIKit.h> 
  10.  
  11. @class BIDDetailViewController; 
  12.  
  13. @interface BIDMasterViewController : UITableViewController 
  14.  
  15. @property (strong, nonatomic) BIDDetailViewController *detailViewController; 
  16. @property (strong, nonatomic) NSArray *presidents; 
  17. @end 

BIDMasterViewController.m


  
  1. // 
  2. //  BIDMasterViewController.m 
  3. //  Presidents 
  4. // 
  5. //  Created by julian on 12-3-25. 
  6. //  Copyright (c) 2012年 __MyCompanyName__. All rights reserved. 
  7. // 
  8.  
  9. #import "BIDMasterViewController.h" 
  10.  
  11. #import "BIDDetailViewController.h" 
  12.  
  13. @implementation BIDMasterViewController 
  14.  
  15. @synthesize detailViewController = _detailViewController; 
  16. @synthesize presidents; 
  17. - (void)awakeFromNib 
  18.     self.clearsSelectionOnViewWillAppear = NO; 
  19.     self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0); 
  20.     [super awakeFromNib]; 
  21.  
  22. - (void)didReceiveMemoryWarning 
  23.     [super didReceiveMemoryWarning]; 
  24.     // Release any cached data, p_w_picpaths, etc that aren't in use. 
  25.  
  26. #pragma mark - View lifecycle 
  27.  
  28. - (void)viewDidLoad 
  29.     [super viewDidLoad]; 
  30.     // Do any additional setup after loading the view, typically from a nib. 
  31.     NSString *path = [[NSBundle mainBundle] pathForResource:@"PresidentList" ofType:@"plist"]; 
  32.     NSDictionary *presidentInfo = [NSDictionary dictionaryWithContentsOfFile:path]; 
  33.     self.presidents = [presidentInfo objectForKey:@"presidents"]; 
  34.     self.detailViewController = (BIDDetailViewController *)[[self.splitViewController.viewControllers lastObject] topViewController]; 
  35.     [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionMiddle]; 
  36.     
  37.  
  38. - (void)viewDidUnload 
  39.     [super viewDidUnload]; 
  40.     // Release any retained subviews of the main view. 
  41.     // e.g. self.myOutlet = nil; 
  42.     self.presidents = nil; 
  43.  
  44. - (void)viewWillAppear:(BOOL)animated 
  45.     [super viewWillAppear:animated]; 
  46.  
  47. - (void)viewDidAppear:(BOOL)animated 
  48.     [super viewDidAppear:animated]; 
  49.  
  50. - (void)viewWillDisappear:(BOOL)animated 
  51.     [super viewWillDisappear:animated]; 
  52.  
  53. - (void)viewDidDisappear:(BOOL)animated 
  54.     [super viewDidDisappear:animated]; 
  55.  
  56. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
  57.     // Return YES for supported orientations 
  58.     return YES; 
  59.  
  60. /* 
  61. // Override to support conditional editing of the table view. 
  62. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath 
  63. { 
  64.     // Return NO if you do not want the specified item to be editable. 
  65.     return YES; 
  66. } 
  67. */ 
  68.  
  69. /* 
  70. // Override to support editing the table view. 
  71. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
  72. { 
  73.     if (editingStyle == UITableViewCellEditingStyleDelete) { 
  74.         // Delete the row from the data source. 
  75.         [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; 
  76.     } else if (editingStyle == UITableViewCellEditingStyleInsert) { 
  77.         // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view. 
  78.     }    
  79. } 
  80. */ 
  81.  
  82. /* 
  83. // Override to support rearranging the table view. 
  84. - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath 
  85. { 
  86. } 
  87. */ 
  88.  
  89. /* 
  90. // Override to support conditional rearranging of the table view. 
  91. - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath 
  92. { 
  93.     // Return NO if you do not want the item to be re-orderable. 
  94.     return YES; 
  95. } 
  96. */ 
  97. /** 
  98.  返回表格的sections 
  99.  */ 
  100. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {  
  101.     return 1; 
  102. /*返回section中的行数*/ 
  103. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
  104.     return [self.presidents count];  
  105. /*设置每行数据*/ 
  106. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
  107.     static NSString *Identifier = @"Master List Cell"
  108.     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:Identifier]; 
  109.     if (!cell) { 
  110.         cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Identifier]; 
  111.     } 
  112.     // Configure the cell. 
  113.     NSDictionary *president = [self.presidents objectAtIndex:indexPath.row];  
  114.     cell.textLabel.text = [president objectForKey:@"name"]; 
  115.     return cell; 
  116. /*当表格被选中时把url传递到detailViewController*/ 
  117. - (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
  118.     NSDictionary *president = [self.presidents objectAtIndex:indexPath.row];  
  119.     NSString *urlString = [president objectForKey:@"url"];  
  120.     self.detailViewController.detailItem = urlString; 
  121. @end 

BIDDetailViewController.h


  
  1. // 
  2. //  BIDDetailViewController.h 
  3. //  Presidents 
  4. // 
  5. //  Created by julian on 12-3-25. 
  6. //  Copyright (c) 2012年 __MyCompanyName__. All rights reserved. 
  7. // 
  8.  
  9. #import <UIKit/UIKit.h> 
  10.  
  11. @interface BIDDetailViewController : UIViewController <UISplitViewControllerDelegate> 
  12.  
  13. @property (strong, nonatomic) id detailItem; 
  14.  
  15. @property (strong, nonatomic) IBOutlet UILabel *detailDescriptionLabel; 
  16. @property (weak, nonatomic) IBOutlet UIWebView *webView;//使用webWiew并使用weak修饰避免循环引用 
  17. @property (strong, nonatomic) UIBarButtonItem *languageButton; 
  18. @property (strong, nonatomic) UIPopoverController *languagePopoverController;//弹出层 
  19. @property (copy, nonatomic) NSString *languageString; 
  20. - (IBAction)touchLanguageButton; 
  21. @end 

BIDDetailViewController.m


  
  1. // 
  2. //  BIDDetailViewController.m 
  3. //  Presidents 
  4. // 
  5. //  Created by julian on 12-3-25. 
  6. //  Copyright (c) 2012年 __MyCompanyName__. All rights reserved. 
  7. // 
  8.  
  9. #import "BIDDetailViewController.h" 
  10. #import "BIDLanguageListController.h" 
  11. @interface BIDDetailViewController () 
  12. @property (strong, nonatomic) UIPopoverController *masterPopoverController; 
  13. - (void)configureView; 
  14. @end 
  15.  
  16. @implementation BIDDetailViewController 
  17. @synthesize languageButton; 
  18. @synthesize languagePopoverController; 
  19. @synthesize languageString; 
  20.  
  21. @synthesize detailItem = _detailItem; 
  22. @synthesize detailDescriptionLabel = _detailDescriptionLabel; 
  23. @synthesize masterPopoverController = _masterPopoverController; 
  24. @synthesize webView; 
  25. //拼接url 
  26. static NSString * modifyUrlForLanguage(NSString *url, NSString *lang) { 
  27.     if (!lang) { 
  28.     return url; } 
  29.     // We're relying on a particular Wikipedia URL format here. This 
  30.     // is a bit fragile! 
  31.     NSRange languageCodeRange = NSMakeRange(7, 2); 
  32.     if ([[url substringWithRange:languageCodeRange] isEqualToString:lang]) { 
  33.         return url; 
  34.     } else { 
  35.         NSString *newUrl = [url stringByReplacingCharactersInRange:languageCodeRange withString:lang]; 
  36.         return newUrl; } 
  37.  
  38. #pragma mark - Managing the detail item 
  39.  
  40. - (void)setDetailItem:(id)newDetailItem 
  41.     if (_detailItem != newDetailItem) { 
  42.       //  _detailItem = newDetailItem; 
  43.         _detailItem = modifyUrlForLanguage(newDetailItem, languageString); 
  44.         // Update the view. 
  45.         [self configureView]; 
  46.     } 
  47.  
  48.     if (self.masterPopoverController != nil) { 
  49.         [self.masterPopoverController dismissPopoverAnimated:YES]; 
  50.     }         
  51.  
  52. - (void)configureView 
  53.     // Update the user interface for the detail item. 
  54.    NSURL *url = [NSURL URLWithString:self.detailItem]; 
  55.    NSURLRequest *request = [NSURLRequest requestWithURL:url];  
  56.     [self.webView loadRequest:request];//加载页面 
  57.     if (self.detailItem) { 
  58.         self.detailDescriptionLabel.text = [self.detailItem description]; 
  59.     } 
  60.  
  61. - (void)didReceiveMemoryWarning 
  62.     [super didReceiveMemoryWarning]; 
  63.     // Release any cached data, p_w_picpaths, etc that aren't in use. 
  64.  
  65. #pragma mark - View lifecycle 
  66.  
  67. - (void)viewDidLoad 
  68.     [super viewDidLoad]; 
  69.     // Do any additional setup after loading the view, typically from a nib. 
  70.     self.languageButton =[[UIBarButtonItem alloc] init]; 
  71.    
  72.     languageButton.title=@"Choose Language"
  73.       //设置languageButton被单击时的处理函数 
  74.     The object that receives an action when the item is selected 
  75.     languageButton.target=self;//目标对象 
  76.     languageButton.action=@selector(touchLanguageButton);//处理方法 
  77.     self.navigationItem.rightBarButtonItem=self.languageButton; 
  78.      
  79.     [self configureView]; 
  80.  
  81. - (void)viewDidUnload 
  82.     [super viewDidUnload]; 
  83.     // Release any retained subviews of the main view. 
  84.     // e.g. self.myOutlet = nil; 
  85.     self.languageButton=nil; 
  86.     self.languagePopoverController=nil; 
  87.  
  88. - (void)viewWillAppear:(BOOL)animated 
  89.     [super viewWillAppear:animated]; 
  90.  
  91. - (void)viewDidAppear:(BOOL)animated 
  92.     [super viewDidAppear:animated]; 
  93.  
  94. - (void)viewWillDisappear:(BOOL)animated 
  95.     [super viewWillDisappear:animated]; 
  96.  
  97. - (void)viewDidDisappear:(BOOL)animated 
  98.     [super viewDidDisappear:animated]; 
  99.  
  100. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
  101.     // Return YES for supported orientations 
  102.     return YES; 
  103.  
  104. #pragma mark - Split view 
  105.  
  106. - (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)popoverController 
  107. //    barButtonItem.title = NSLocalizedString(@"Master", @"Master"); 
  108.     barButtonItem.title = NSLocalizedString(@"Presidents", @"Presidents"); 
  109.     [self.navigationItem setLeftBarButtonItem:barButtonItem animated:YES]; 
  110.     self.masterPopoverController = popoverController; 
  111.  
  112. - (void)splitViewController:(UISplitViewController *)splitController willShowViewController:(UIViewController *)viewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem 
  113.     // Called when the view is shown again in the split view, invalidating the button and popover controller. 
  114.     [self.navigationItem setLeftBarButtonItem:nil animated:YES]; 
  115.     self.masterPopoverController = nil; 
  116. //选择语言并重在detailView 
  117. - (void)setLanguageString:(NSString *)newString { 
  118.     NSLog(@"setLanguageString:"); 
  119.     if (![newString isEqualToString:languageString]) { 
  120.         languageString = [newString copy]; 
  121.         self.detailItem = modifyUrlForLanguage(_detailItem, languageString);  
  122.     } 
  123.     if (languagePopoverController != nil) {  
  124.         [languagePopoverController dismissPopoverAnimated:YES]; 
  125.         self.languagePopoverController = nil; 
  126.     }  
  127. //langoageButton时显示弹出层 
  128. -(IBAction)touchLanguageButton{ 
  129.     NSLog(@"touchLanguageButton"); 
  130.     if(self.languagePopoverController==nil){ 
  131.         BIDLanguageListController * languageListController=[[BIDLanguageListController alloc] init]; 
  132.         languageListController.detailViewController = self; 
  133.         UIPopoverController *poc=[[UIPopoverController alloc] initWithContentViewController:languageListController]; 
  134.         [poc presentPopoverFromBarButtonItem:languageButton 
  135.                     permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 
  136.         self.languagePopoverController = poc; 
  137.  
  138.     }else
  139.         if(languagePopoverController!=nil){ 
  140.             [languagePopoverController dismissPopoverAnimated:YES]; 
  141.             self.languagePopoverController=nil; 
  142.              
  143.         } 
  144.     } 
  145. @end 

BIDLanguageListController.h


  
  1. // 
  2. //  BIDLanguageListController.h 
  3. //  Presidents 
  4. //  右上弹出层 
  5. //  Created by julian on 12-4-8. 
  6. //  Copyright (c) 2012年 __MyCompanyName__. All rights reserved. 
  7. // 
  8. #import <UIKit/UIKit.h> 
  9. @class BIDDetailViewController; 
  10. @interface BIDLanguageListController : UITableViewController 
  11. @property (weak, nonatomic) BIDDetailViewController *detailViewController; 
  12. @property (strong, nonatomic) NSArray *languageNames; 
  13. @property (strong, nonatomic) NSArray *languageCodes; 
  14. @end 

BIDLanguageListController.m


  
  1. // 
  2. //  BIDLanguageListController.m 
  3. //  Presidents 
  4. // 
  5. //  Created by julian on 12-4-8. 
  6. //  Copyright (c) 2012年 __MyCompanyName__. All rights reserved. 
  7. // 
  8.  
  9. #import "BIDLanguageListController.h" 
  10. #import "BIDDetailViewController.h" 
  11. @implementation BIDLanguageListController 
  12. @synthesize languageNames;  
  13. @synthesize languageCodes; 
  14. @synthesize detailViewController; 
  15. - (id)initWithStyle:(UITableViewStyle)style 
  16.     self = [super initWithStyle:style]; 
  17.     if (self) { 
  18.         // Custom initialization 
  19.     } 
  20.     return self; 
  21.  
  22. - (void)didReceiveMemoryWarning 
  23.     // Releases the view if it doesn't have a superview. 
  24.     [super didReceiveMemoryWarning]; 
  25.      
  26.     // Release any cached data, p_w_picpaths, etc that aren't in use. 
  27.  
  28. #pragma mark - View lifecycle 
  29.  
  30. - (void)viewDidLoad 
  31.     [super viewDidLoad]; 
  32.  
  33.     // Uncomment the following line to preserve selection between presentations. 
  34.     // self.clearsSelectionOnViewWillAppear = NO; 
  35.   
  36.     // Uncomment the following line to display an Edit button in the navigation bar for this view controller. 
  37.     // self.navigationItem.rightBarButtonItem = self.editButtonItem; 
  38.     self.languageNames = [NSArray arrayWithObjects:@"English", @"French", @"German", @"Spanish",@"中文",nil]; 
  39.     self.languageCodes = [NSArray arrayWithObjects:@"en", @"fr", @"de", @"es",@"zh", nil];  
  40.     self.clearsSelectionOnViewWillAppear = NO; 
  41.     //设置试图大小,弹出层控制器会自动包裹(把此值设置为Popover自己的属性popoverContentSize) 
  42.     self.contentSizeForViewInPopover = CGSizeMake(150.0, [self.languageCodes count] * 44.0); 
  43.  
  44. - (void)viewDidUnload 
  45.     [super viewDidUnload]; 
  46.     // Release any retained subviews of the main view. 
  47.     // e.g. self.myOutlet = nil; 
  48.     self.detailViewController = nil;  
  49.     self.languageNames = nil;  
  50.     self.languageCodes = nil; 
  51.  
  52. - (void)viewWillAppear:(BOOL)animated 
  53.     [super viewWillAppear:animated]; 
  54.  
  55. - (void)viewDidAppear:(BOOL)animated 
  56.     [super viewDidAppear:animated]; 
  57.  
  58. - (void)viewWillDisappear:(BOOL)animated 
  59.     [super viewWillDisappear:animated]; 
  60.  
  61. - (void)viewDidDisappear:(BOOL)animated 
  62.     [super viewDidDisappear:animated]; 
  63.  
  64. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
  65.     // Return YES for supported orientations 
  66.     return YES; 
  67.  
  68. #pragma mark - Table view data source 
  69.  
  70. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
  71. #warning Potentially incomplete method implementation. 
  72.     // Return the number of sections. 
  73.     return 1; 
  74.  
  75. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
  76. #warning Incomplete method implementation. 
  77.     // Return the number of rows in the section. 
  78.     return [self.languageCodes count]; 
  79.  
  80. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
  81.     static NSString *CellIdentifier = @"Cell"
  82.      
  83.     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
  84.     if (cell == nil) { 
  85.         cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
  86.     } 
  87.      
  88.     // Configure the cell... 
  89.     cell.textLabel.text = [languageNames objectAtIndex:[indexPath row]]; 
  90.     return cell; 
  91.  
  92. /* 
  93. // Override to support conditional editing of the table view. 
  94. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath 
  95. { 
  96.     // Return NO if you do not want the specified item to be editable. 
  97.     return YES; 
  98. } 
  99. */ 
  100.  
  101. /* 
  102. // Override to support editing the table view. 
  103. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
  104. { 
  105.     if (editingStyle == UITableViewCellEditingStyleDelete) { 
  106.         // Delete the row from the data source 
  107.         [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; 
  108.     }    
  109.     else if (editingStyle == UITableViewCellEditingStyleInsert) { 
  110.         // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view 
  111.     }    
  112. } 
  113. */ 
  114.  
  115. /* 
  116. // Override to support rearranging the table view. 
  117. - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath 
  118. { 
  119. } 
  120. */ 
  121.  
  122. /* 
  123. // Override to support conditional rearranging of the table view. 
  124. - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath 
  125. { 
  126.     // Return NO if you do not want the item to be re-orderable. 
  127.     return YES; 
  128. } 
  129. */ 
  130.  
  131. #pragma mark - Table view delegate 
  132.  
  133. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
  134.      detailViewController.languageString = [self.languageCodes objectAtIndex: [indexPath row]]; 
  135.  
  136. @end