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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:12:45+00:00 2026-06-02T01:12:45+00:00

Here’s what I’ve got: I have a root view controller with an array of

  • 0

Here’s what I’ve got:

I have a root view controller with an array of images. I have a detailViewController which simply has a fullscreen UIImageView for displaying a full screen image. I also have a segue defined that presents the detailViewController. This segue is programmatically invoked when the user selects an image in the rootViewController like so:

- (void)carousel:(iCarousel *)carousel didSelectItemAtIndex:(NSInteger)index
{
    [self performSegueWithIdentifier:@"fullScreenSegue" sender:self];
}

The problem is that the detailViewController has an image property that it sets as the image for the UIImageView it displays and I need a way to pass the image to it to display. How do I do this? According to apple docs, I should implement the prepareForSegue method in the calling controller, but at that point, I no longer have access to the index above. The images are in an array in the root view controller and I need that index to know which image to pass to the detailViewController. I also set the detailViewController to have a protocol that sets the calling controller as the delegate and then calls a “setImage” method in the init() method, but that doesn’t even seem to work and seems like a crazy implementation anyway…

I thought about declaring a property in the rootViewController like @property int selectedIndex, then setting that property in the above method and then in the prepareForSegue method doing something like:

detailViewController.imageForDisplay = [images objectAtIndex:selectedIndex];

That would probably work, but that approach rubs me wrong…

Thanks in advance for the help!

  • 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-02T01:12:47+00:00Added an answer on June 2, 2026 at 1:12 am

    Two ways to handle it. One use prepareForSegue and save your index somewhere before you call the segue…

    self.selectedIndex = index;
    [self performSegueWithIdentifier:@"fullScreenSegue" sender:self];
    

    then in the prepareForSegue use:

    if([[segue identifier] isEqualToString:@"fullScreenSegue"])
    {
        DetailViewController *detailViewController = segue.destinationViewController;
        detailViewController.imageForDisplay = [self.images objectAtIndex:self.selectedIndex];
    }
    

    Second way is to use your delegate and protocol, but make the setImage call in your viewDidLoad method, not in your init.

    Hope that helps. It seems like you were getting pretty close.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is an example: I have a file 1.js, which has some functions. I
Here is my problem : I have a post controller with the action create.
Here's the basic setup: I have a thin bar at the top of a
Here's my procedure: DROP PROCEDURE IF EXISTS `couponExpires`$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `couponExpires`(IN couponID BIGINT,
Here is an example: I have the generic type called Account. I wish to
Here I have an int x=3; NSLog(@%i, x); How to have it displayed like
Here is my code...I have two dimensional matrices A,B. I want to develop the
here's what we have today: * NxM grid of points in 3D * we
Here is my code (Say we have a single button on the page that
Here is what I am trying to achieve in PHP: I have this string:

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.