Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8372613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:28:39+00:00 2026-06-09T14:28:39+00:00

in the begining iOS 5 Development exploring the iOS sdk chapter 11 iPad Considerations,the

  • 0

in the begining iOS 5 Development exploring the iOS sdk chapter 11 “iPad Considerations”,the “Creating Your Own Popover” paragraph,i try it my self,but just give an error output “Terminating app due to uncaught exception ‘NSInternalInconsistencyException‘, reason: ‘UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:‘”
codes as follows:(because I am first ask question on the stackoverflow website and my english is poor ,so just forgive my fault on the expression)
1.PrLanguageListController.h

#import <UIKit/UIKit.h>
@class PrDetailViewController;
@interface PrLanguageListController : UITableViewController
@property (weak, nonatomic) PrDetailViewController *detailViewController;
@property (strong, nonatomic) NSArray *languageNames;
@property (strong, nonatomic) NSArray *languageCodes;
@end

2.PrLanguageListContrller.m

#import "PrLanguageListController.h"
#import "PrDetailViewController.h"
@interface PrLanguageListController ()
@end

@implementation PrLanguageListController
@synthesize detailViewController;
@synthesize languageCodes;
@synthesize languageNames;
- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
   return self;
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    self.languageNames = [NSArray arrayWithObjects:@"English", @"French",
                          @"German", @"Spanish", nil];
    self.languageCodes = [NSArray arrayWithObjects:@"en", @"fr", @"de", @"es", nil];
    self.clearsSelectionOnViewWillAppear = NO;
    self.contentSizeForViewInPopover = CGSizeMake(320.0,
                                                  [self.languageCodes count] * 44.0);
}

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

- (BOOL)shouldAutorotateToInterfaceOrientation:    (UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    return [self.languageCodes count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    // Configure the cell...
    cell.textLabel.text = [languageNames objectAtIndex:[indexPath row]];
    return cell;
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    detailViewController.languageString = [self.languageCodes objectAtIndex:
                                       [indexPath row]];
}
@end

3.PrDetailViewController.h

#import <UIKit/UIKit.h>
@interface PrDetailViewController : UIViewController <UISplitViewControllerDelegate>
@property (strong, nonatomic) id detailItem;
@property (strong, nonatomic) IBOutlet UILabel *detailDescriptionLabel;
@property (weak, nonatomic) IBOutlet UIWebView *webView;
@property (strong, nonatomic) UIBarButtonItem *languageButton;
@property (strong, nonatomic) UIPopoverController *languagePopoverController;
@property (copy, nonatomic) NSString *languageString;
- (IBAction)touchLanguageButton;
@end

4.PrDetailViewController.m

#import "PrDetailViewController.h"
#import "PrLanguageListController.h"
@interface PrDetailViewController ()
@property (strong, nonatomic) UIPopoverController *masterPopoverController;
- (void)configureView;
@end
@implementation PrDetailViewController
@synthesize detailItem = _detailItem;
@synthesize detailDescriptionLabel = _detailDescriptionLabel;
@synthesize masterPopoverController = _masterPopoverController;
@synthesize webView;
@synthesize languageButton;
@synthesize languagePopoverController;
@synthesize languageString;
#pragma mark - Managing the detail item
//rewrite url for different languages.eg.www.wekipak.com/us--ch...etc
static NSString * modifyUrlForLanguage(NSString *url, NSString *lang) {
    if (!lang) {
        return url;
    }
// We're relying on a particular Wikipedia URL format here. This
// is a bit fragile!
NSRange languageCodeRange = NSMakeRange(7, 2);
if ([[url substringWithRange:languageCodeRange] isEqualToString:lang]) {
    return url;
    } else {
        NSString *newUrl = [url stringByReplacingCharactersInRange:languageCodeRange
                                                    withString:lang];
        return newUrl;
    }
}
- (void)setDetailItem:(id)newDetailItem
{
    if (_detailItem != newDetailItem) {
        //_detailItem = newDetailItem;
        _detailItem = modifyUrlForLanguage(newDetailItem, languageString);
        // Update the view.
        [self configureView];
    }
if (self.masterPopoverController != nil) {
    [self.masterPopoverController dismissPopoverAnimated:YES];
    }        
}
- (void)configureView
{
    // Update the user interface for the detail item.
    NSURL *url = [NSURL URLWithString:self.detailItem];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [self.webView loadRequest:request];
    if (self.detailItem) {
        self.detailDescriptionLabel.text = [self.detailItem description];
    }
}
- (void)viewDidLoad
{
    [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
    self.languageButton = [[UIBarButtonItem alloc] init];
    languageButton.title = @"Choose Language";
    languageButton.target = self;
    languageButton.action = @selector(touchLanguageButton);
    self.navigationItem.rightBarButtonItem = self.languageButton;
    [self configureView];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    self.detailDescriptionLabel = nil;
    self.webView = nil;
    self.languageButton = nil;
    self.languagePopoverController = nil;
}
- (void)setLanguageString:(NSString *)newString {
    if (![newString isEqualToString:languageString]) {
        languageString = [newString copy];
        self.detailItem = modifyUrlForLanguage(_detailItem, languageString);
    }
    if (languagePopoverController != nil) {
        [languagePopoverController dismissPopoverAnimated:YES];
        self.languagePopoverController = nil;
    }
}
- (IBAction)touchLanguageButton {
    if (self.languagePopoverController == nil) {
    PrLanguageListController *languageListController =
    [[PrLanguageListController alloc] init];
    languageListController.detailViewController = self;
    UIPopoverController *poc = [[UIPopoverController alloc]
                                initWithContentViewController:languageListController];
    [poc presentPopoverFromBarButtonItem:languageButton
                permittedArrowDirections:UIPopoverArrowDirectionAny
                                animated:YES];
    self.languagePopoverController = poc;
    } else {
    if (languagePopoverController != nil) {
        [languagePopoverController dismissPopoverAnimated:YES];
        self.languagePopoverController = nil;
        }
    }
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}
#pragma mark - Split view
- (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)popoverController
{
    barButtonItem.title = NSLocalizedString(@"Presidents", @"Presidents");
    //barButtonItem.title = NSLocalizedString(@"Master", @"Master");
    [self.navigationItem setLeftBarButtonItem:barButtonItem animated:YES];
    self.masterPopoverController = popoverController;
}
- (void)splitViewController:(UISplitViewController *)splitController willShowViewController:(UIViewController *)viewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
    // Called when the view is shown again in the split view, invalidating the button      and popover controller.
[self.navigationItem setLeftBarButtonItem:nil animated:YES];
self.masterPopoverController = nil;
}
@end

when choose the change the language tap button it running down,and give the terminal exception…
output:
2012-05-27 19:20:37.803 Presidents[4864:f803] * Assertion failure in -[UITableView _createPreparedCellForGlobalRow:withIndexPath:], /SourceCache/UIKit_Sim/UIKit-1914.84/UITableView.m:6061
2012-05-27 19:20:37.804 Presidents[4864:f803]
Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:’
*
* First throw call stack:
(0x13ce022 0x155fcd6 0x1376a48 0x9af2cb 0xb2d28 0xb33ce 0x9ecbd 0xad6f1 0x56d21 0x13cfe42 0x1d86679 0x1d90579 0x1d90674 0x50967 0x4b84e9 0x4b9548 0x3ee9 0x13cfe99 0x1b14e 0x259a0e 0x13cfe99 0x1b14e 0x1b0e6 0xc1ade 0xc1fa7 0xc1266 0x403c0 0x405e6 0x26dc4 0x1a634 0x12b8ef5 0x13a2195 0x1306ff2 0x13058da 0x1304d84 0x1304c9b 0x12b77d8 0x12b788a 0x18626 0x23dd 0x2345 0x1)
terminate called throwing an exception(lldb)

How could i solve this problem ? thanksgiving …

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T14:28:40+00:00Added an answer on June 9, 2026 at 2:28 pm

    You need to add alloc/init of your cell in PrLanguageListContrller.m

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
        {
            static NSString *CellIdentifier = @"Cell";
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
            // Configure the cell...
    

    add this

    **if (cell == nil) cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];**
    

    …

        cell.textLabel.text = [languageNames objectAtIndex:[indexPath row]];
        return cell;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just beginning iOS development and I am getting a crash on creating an UITabBarController
I am currently reading 'Beginning iOS 5 Games Development: Using the iOS SDK for
I'm a newbie, and plainly started with a sample code from the book 'Beginning-iOS-5-Games-Development'.
As a beginning iOS developer, which approach allows for quicker more efficient development?
Begining with JSP and servlet development, I have some problems with a bodyless custom
I'm only really beginning IOS development but have a few years dev of ASP.net
I'm a beginning to iOS development. My objective is to reduce load-time perception during
How to use ios 5 sdk's asynchronous http get requests to handle redirected urls?
I am in a process of learning ios development. I am beginning to learn
I have the Facebook iOS SDK set up in my app. However, I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.