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 9215015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:06:23+00:00 2026-06-18T02:06:23+00:00

i am working on a uitableview and i am getting random crashes with when

  • 0

i am working on a uitableview and i am getting random crashes with when i use custom uiviewcontroller inside a uitableviewcell.

static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(!cell){
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    SuspectSalesResponse* r = [valueArray objectAtIndex:indexPath.row];
    SuspectSalesCellViewController* scellView = [[SuspectSalesCellViewController alloc]initWithNibName:@"SuspectSalesCellViewController" bundle:nil cellData:r];
    if(![cellViewArray containsObject:scellView])        
       [cellViewArray addObject:scellView];
    [cell.contentView addSubview:scellView.view];

}
return cell;

This code sometimes work, sometimes it gives the folowing error:

* -[SuspectSalesHeaderViewController _parentModalViewController]: message sent to deallocated instance 0x8556880

i’ve tried keeping contentviews within an array (cellViewArray) but no luck i am still getting this error. What am i doing wrong?

Thanks for helping!

  • 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-18T02:06:24+00:00Added an answer on June 18, 2026 at 2:06 am

    The problem is that you are not supposed to add view controllers inside table cells. You should try to change from UIViewController to UIView.

    The exact reason for your crash is that you create a controller (which has a view) and you are adding the view to your cell, but the controller object is lost. When the view sends whatever notification to it’s parent controller, the controller is already deallocated and there is where you get your bad access. This will be solved if you transform your SuspectSales~ to a UIView subclass

    EDIT
    To load a UIView (or any subclass) from a nib file, you must first create the xib, set the view’s class to your class (you do it in the third tab on the interface builder).

    After that, you can load it with this code:

    Generic function in some utility class

    + (id)loadNibNamed:(NSString *)nibName ofClass:(Class)objClass {
        if (nibName && objClass) {
            NSArray *objects = [[NSBundle mainBundle] loadNibNamed:nibName owner:nil options:nil];
    
            for (id currentObject in objects ){
                if ([currentObject isKindOfClass:objClass])
                    return currentObject;
            }
        }
    
        return nil;
    }
    

    In your class:

    Subclass *view = [UtilityClass loadNibNamed:@"Subclass" ofClass:[Subclass class]];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

why is detailTextLabel not working anymore? - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static
hi i am working on UITableView custom cell for twitter, for each cell i
I'm working with a UITableView and a custom UITableViewCell . Initially, this had poor
I am working on custom cell in uitableview and trying to add uilabels in
I've working on a program and I'm having issues getting a tableView to update.
This is my first time I am working on UITableView connected to custom delegate
I am working with the UITableView where i am getting the data from the
I'm working on a custom Pulse style UITableView according to this tutorial , and
Hi i have a working UITableViewController and UITableView with custom cells but i want
How to change uitableview cell background image? I write this code, it's not working.

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.