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

  • Home
  • SEARCH
  • 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 7076741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:20:07+00:00 2026-05-28T06:20:07+00:00

UPDATE – Cause found! … please read below & suggest the solution: While creating

  • 0

UPDATE – Cause found!… please read below & suggest the solution:

While creating a video to show this issue, I have found why does that happen…

Any Control/Element that is defined between #imports & @implementation DetailViewController in .m file is lost by the original detVC when a new instance is created of VC.

Example:
I am including a video that re-creates this issue. As shown, all controls work except a UISegmentedControl & a UILabel.. both of which are defined in DetailViewController.m as:

#import "DetailViewController.h"

UISegmentedControl *sortcontrol;
UILabel *incrementLabel;

@implementation DetailViewController

Video Link – http://www.youtube.com/watch?v=2ABdK0LkGiA

I think we are pretty close.. Waiting for the answer!!

P.S.: I think this info is enough can lead us to the solution, but if needed I can share the code too.


EARLIER:

There’s a detailViewController (detVC) in our app which is normally ‘pushed’ from a UITableViewController.

Now we are also implementing Push Notifications which would ‘modally’ present the same detVC whenever the notification arrives, which in turn can happen over any view controller.

It works all fine until the detVC through notification is presented while another instance of detVC was already the active view controller (pushed earlier through TableView).

The problem happens when the presented detVC is dismissed – the pushed detVC ‘looses’ control of about everything – It is not pointing to the same data as earlier & even the UISegmentedControl on Navigation Toolbar points to -1 index on pressing any index!

Why does such thing happen when we are creating a separate instance of detVC? Why does it affect the earlier detVC? How can it be resolved / What about Objective C needs to be learned here? (FYI, we are using ARC in the project)

Thanks


EDIT – Some code:

When Pushed:

ProductDetailViewController *detailViewController = [[ProductDetailViewController alloc] init];    
detailViewController.hidesBottomBarWhenPushed = YES;  
[self.navigationController pushViewController:detailViewController animated:YES];
detailViewController.serverOffset=serverOffset;
detailViewController.prdctIndex = indexPath.row;

When presented through Notification:

- (void)displaySingleProduct:(NSDictionary*)userInfo{
    ProductDetailViewController *onePrdVC = [[ProductDetailViewController alloc] init];    
    UINavigationController *addNav = [[UINavigationController alloc] initWithRootViewController:onePrdVC];
    onePrdVC.justOne=YES;
    onePrdVC.onePrdIDtoLoad=[[[userInfo valueForKey:@"prd"] valueForKey:@"id"] intValue];
    [self.navigationController presentModalViewController:addNav animated:YES];
}

There is a Product class in detVC which gets the data from the values stored at the prdctIndex row in the SQLite table.

After dismissing the presented detVC through notification, the Product class of the pushed detVC starts pointing to the row which was used for Product class in presented detVC. And there is no such code in viewDidAppear which would alter Product class.

So, this, UISegmentedControl issue mentioned above & some other problems are causing the pain! Basically, the whole detVC acts weird – which re-works if we just pop & re-push it!


EDIT 2

I have more info on it which could lead to the cause.
If I run viewDidLoad on viewDidAppear like this:

if (!justOne) {
    aProduct = [allProducts getProduct:(prdctIndex+1) one:NO];
    [self viewDidLoad];
    [self populateDetails];
}

the pushed detVC regains the control & every element/control starts re-working as expected (but not in the ideal way). So, it is quite clear that the separate instance of presented detVC does messes up the earlier pushed detVC & a re-setting up of all the controls / pointers is required through viewDidLoad.

Can any helpful conclusion can be derived from this info?

  • 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-05-28T06:20:07+00:00Added an answer on May 28, 2026 at 6:20 am

    When in your code you write:

    #import "DetailViewController.h"
    
    UISegmentedControl *sortcontrol;
    UILabel *incrementLabel;
    
    @implementation DetailViewController
    

    You are not defining these variables as instance variables (ivars), so they are not individual for each instance. There are three ways to define ivars.
    1) The traditional way, in your .h file.

    @interface DetailViewController{
        UISegmentedControl *sortcontrol;
        UILabel *incrementLabel; 
    }
    

    2) Some additions to objective-C have added support for the next two ways. Like declaring them in your .m file.

    @implementation DetailViewController{
        UISegmentedControl *sortcontrol;
        UILabel *incrementLabel;
    }
    

    3) If these ivars use properties to expose them, then you can simply leave out the explicit definition of them. So in .h:

    @interface DetailViewController
    @property (strong, nonatomic) IBOutlet UISegmentedControl *sortcontrol;
    @property (strong, nonatomic) IBOutlet UILabel *incrementLabel;
    

    and then in the .m file:

    @implementation DetailViewController
    @synthesize sortcontrol;
    @synthesize incrementLabel;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Update: Please read this question in the context of design principles, elegance, expression of
Update : I found the solution by removing v.setFocusable(true); v.setClickable(true); in the code and
Update: Solved, with code I got it working, see my answer below for the
UPDATE: Focus your answers on hardware solutions please. What hardware/tools/add-in are you using to
UPDATE - A comprehensive comparison, updated as of February 2015, can be found here:
[UPDATE] Was just an idiot mistake. See end for solution. I am trying to
UPDATE - I'm probably being daft, see my last update below. I just did
UPDATE: Please see https://softwarerecs.stackexchange.com/questions/71464/java-library-to-insert-invisible-text-into-a-pdf instead. I want to insert invisible text into an existing
Update I asked this question quite a while ago now, and I was curious
Update: I add a while to get the remain data, problem solved. thanks you

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.