Note that there are some explanatory texts on larger screens.

plurals
  1. POInstance variables not working in ViewController in UINavigationController
    primarykey
    data
    text
    <p>I'm still new to iOS development but I've ran into a problem that I can't solve and I've tried looking online but can't find anything yet.</p> <p>I'm using a UIImagePickerController to pick and image and I'm using it in the App Delegate. When an image is returned, in the imagePickerController:didFinishPickingMediaWithInfo method, I want to make a new navigation controller with a view controller and put it over the "app".</p> <p>Here is how I'm doing it:</p> <pre><code>CustomNavigationController *customNavigationController = [[CustomNavigationController alloc] init]; PhotoViewController *photoViewController = [[PhotoViewController alloc] initWithNibName:@"PhotoViewController" bundle:[NSBundle mainBundle]]; [customNavigationController pushViewController:photoViewController animated:NO]; [customNavigationController.view setFrame:[[UIScreen mainScreen] applicationFrame]]; [photoViewController release]; [self.window addSubview:customNavigationController.view]; //Call method of photoViewController. [[customNavigationController.viewControllers objectAtIndex:0] addPhotoFromData:info]; [self.tabBarController dismissViewControllerAnimated:YES completion:nil]; //Get rid of UIImagePickerController </code></pre> <p>However in the photoViewController, I don't have access to any instance variables synthesized and loaded in viewDidLoad. They all return to null. There is also a tableView and calls to reload the tableView do not actually cause the tableView to respond.</p> <p>Here is some of the code from photoViewController</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; self.photoCount = 0; self.timestamp = [[NSDate date] timeIntervalSince1970]; self.photos = [[NSMutableArray alloc] initWithCapacity:5]; self.photosData = [[NSMutableArray alloc] initWithCapacity:5]; self.uploadingCount = 0; UINib *customCell = [UINib nibWithNibName:@"CustomTableCell" bundle:[NSBundle mainBundle]]; [self.tableView registerNib:customCell forCellReuseIdentifier:@"customCell"]; self.tableView.separatorColor = [UIColor clearColor]; NSLog(@"%@", self); } </code></pre> <p>and also the addPhotoFromData method:</p> <pre><code>- (void)addPhotoFromData:(NSDictionary *)info { [self.photos addObject:info]; NSLog(@"%@", self.photos); //Doesn't add "info" and does not return anything when later called from other methods. [self.tableView reloadData]; //Doesn't work </code></pre> <p>Everything was working before I add in the UINavigationController. I'm completely lost.</p> <p><strong>EDIT:</strong> After some more debugging attempts, I have discovered that the view is not loaded when addPhotoFromData is called. viewDidLoad is called afterwords. Is there a way to delay method calls?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload