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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:11:24+00:00 2026-05-27T19:11:24+00:00

I have differents UIViewController that contains components that appear and disappear from the view

  • 0

I have differents UIViewController that contains components that appear and disappear from the view (with animation like translation movment).
I would like to have a single class that reduce the amount of code in each UIViewController and that can be configured in XIB files.

So my XIB file contains :

  • The component that need to move between two location (it’s “My View” in the following screenshot)
  • vVisible : A UIView that acts like an indicator to represent the visible location
  • vHidden : A UIView that acts like an indicator to represent the hidden location

Here is what it looks like in XCode :

enter image description here

And I create a AppearingController (which is also a UIViewController). It controls the animation that make the component appear or disappear. It has 3 IBOutlet properties :

IBOutlet UIView * vVisible;
IBOutlet UIView * vHidden;
IBOutlet UIView * v;

And a public method (just that run the animation between the rect of the vVisible and the rect of the vHidden views) :

-(void) showVisible:(BOOL)visible {
CGRect frameDst = self.vVisible.frame;
if(!self.visible) frameDst = self.vHidden.frame;

CGPoint p = CGPointMake(CGRectGetMidX(frameDst), CGRectGetMidY(frameDst));
self.currentPosition = p;

CABasicAnimation *frameTranslation = [CABasicAnimation animationWithKeyPath:@"position"];
frameTranslation.toValue = [NSValue valueWithCGPoint:p];    
frameTranslation.duration = 0.40;
frameTranslation.repeatCount = 1;
frameTranslation.removedOnCompletion = NO;
frameTranslation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
frameTranslation.cumulative = NO;
frameTranslation.additive = NO;
frameTranslation.delegate = self;
[self.v addAnimation:frameTranslation forKey:@"position"];
}

So, in my UIViewController code, I just need a few code :

  • In the header file : the iboutlet/property to bind to the AppearingController instance of the XIB.
  • In the implementation file : i can call [self.appearingController showVisible:FALSE] to run the animation to hide/unhide the component

And … it works.
But I’m not quite satisfied because, I feel like it’s a bit twisted and heavy. Because :

  • The AppearingController is a UIViewController (I did not manage with object or external object from the objects library).
  • vVisible and vHidden are views but I don’t need view method/functionalities. I just need the view.frame to indicate the location.

This approach seems is good way to you ?

How can you improve it ?

Do you have some pattern you use to achieve this same goal ?

I’m interested

Thanks.

  • 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-27T19:11:24+00:00Added an answer on May 27, 2026 at 7:11 pm

    This seems fairly good ! You can code this in a number of ways actually. But when it comes to this specific example, it does not matter if you want a better approach in coding. When you take up a much much bigger project it is necessary that you design your data structures and coding scheme such that you get it done in the most time constraint and optimized manner!

    For example, In a much bigger project where you need to handle 100 images , you could just create a class for animation and subclass them accordingly and either reference them or inherit them so that your approach is logical and time-saving. Hope you got the point !

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

Sidebar

Related Questions

I have a UIViewController that I want to load from a NIB that has
First a little background info: I have UIViewController that contains a UITableView. In the
I have a UIViewController that should lazily load a view and then keep it
Possible Duplicate: Create a UIViewController that contain a UIViewController I have a parent view
In my iPhone app I have a UIViewController that has a UITableView and another
In a custom UIViewController , if I have a member UINavigationController that I initialize
i have a UIViewController class that do the following: detect movement. array a bunch
i am using UIviewcontroller subclasses. In my main view i have 3 buttons, each
I have a UITabBarController, and each tab handles a different UIViewController that pushes on
I have a UIViewController that returns YES in shouldAutorotateToInterfaceOrientation: for UIDeviceOrientationPortrait and NO for

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.