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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:57:03+00:00 2026-06-12T18:57:03+00:00

I have a viewcontroller, if I press a button, another viewController is loaded, but

  • 0

I have a viewcontroller, if I press a button, another viewController is loaded, but the first is not unloaded. I want to access a variable form the first view controller from the second, actually a UIScrollView, so that I can use it in this way:

scroll1.hidden = YES;

How can I do this? I tried importing the .h file, but still I cannot use the UIScrollView

EDIT:

NSArray* stack = [self.navigationController viewControllers];
NSInteger currentIndex = [stack indexOfObject:self];
ViewController* linkToA = (ViewController*)[stack objectAtIndex:currentIndex - 1];

[linkToA.scroll1.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
[linkToA.scroll1 addSubview:linkToA.backgroundImage];

or

ViewController *linkToA = [[ViewController alloc] init];
linkToA = (ViewController*)self.presentingViewController;

[linkToA.scroll1.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
[linkToA.scroll1 addSubview:linkToA.backgroundImage];
  • 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-12T18:57:04+00:00Added an answer on June 12, 2026 at 6:57 pm

    just make sure first view controller does have a property of your scrollView in the header:

    @property (nonatomic, strong) UIScrollView *scrollView;
    

    if you don’t have a latest xcode put @synthesize scrollView to the implementation of the first controller

    lets say your first controller is A and the second is B

    if B is a added as a modal then use this:

    linkToA = (A*)B.presentingViewController;
    

    if B is added to navigationControllerStack:

    NSArray* stack = [B.navigationController viewControllers];
    NSInteger currentIndex = [stack indexOfObject:B];
    linkToA = (A*)[stack objectAtIndex:currentIndex - 1];
    

    after you have a linkToA you have to do

    linkToA.scrollView.hidden = YES;
    

    hope this will help

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

Sidebar

Related Questions

I have a button that pushes another viewcontroller onto my navigationcontroller. When I press
I want to switch to another viewController. I have an UIButton on my view,
I want to have a ViewController that has a table view on the top
I have a view, and a button in this view. When I press this
I have already posted my this problem another time but i have not got
I have a viewcontroller like the following. But the touchsBegan doestnt get detected. Can
I have built an app where the user can press a button and get
I have a ViewController whose view results from data from a fetch request with
I need to implement a scroll view which (on a button press) will page
I have another orientation problem. But this one is very tricky. My RootViewController is

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.