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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:38:36+00:00 2026-05-23T04:38:36+00:00

I have a UIView in my class (besides the original view) made in interface

  • 0

I have a UIView in my class (besides the original view) made in interface builder.

@interface TimeLineGrid : UIViewController {

UIView *toggleView;

}

@property (nonatomic, retain) IBOutlet UIView *toggleView;

I have synthesized it as well. I have implemented a swipe gesture so that when swiped up, the toggle view is added and when swiped down the toggle view is removed.

-(void)swipedUp {

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:2.0f];

    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:NO];

    [self.view addSubview:self.toggleView];

    [UIView commitAnimations];



}

-(void)swipedDown {

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:2.0f];

    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:NO];

    [self.toggleView removeFromSuperview];

    [UIView commitAnimations];

}

It works fine when I swipe up once and when I swipe down after that. But when i swipe up once again, it crashes with EXC_BAD_ACCESS error. I know this has something to do with the retain count increasing when I addSubview and reducing when I removeSubview. Can someone shed more light on this? How do I achieve this toggle?

EDIT:
My view hierarchy is as follows:

->UIView (toggleView)
->UIView (mainView to which toggleView is being added)
 -->UIToolBar
  • 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-23T04:38:37+00:00Added an answer on May 23, 2026 at 4:38 am

    Most likely, the view is being released when you call [self.toggleView removeFromSuperview];. I recommend that you restructure your code a little.

    Since you are creating the view in IB, declare it in the header file as

    IBOutlet UIView *toggleView;
    

    Do not include the property call or the synthesize. Since you are not setting or getting the toggleView, just refer to it by the pointer.

    In the implementation, set the pointer to nil in viewDidUnload and release it in dealloc. Then, adjust your toggle methods as follows:

    -(void)swipedUp {
        if (![toggleView superview]) {
    
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:2.0f];
    
            [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:NO];
    
            [self.view addSubview:toggleView];
    
            [UIView commitAnimations];
        }
    }
    
    -(void)swipedDown {
    
        if ([toggleView superview]) {
    
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:2.0f];
    
            [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:NO];
    
            [toggleView removeFromSuperview];
    
            [UIView commitAnimations];
        }
    }
    

    Here, the if clause will catch the event that the user swipes up twice in a row and not respond to the second swipe. Notice also that this uses toggleView in place of self.toggleView.

    This should resolve the problem.

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

Sidebar

Related Questions

I have a property in my UIView class, something like that: myView.h @ interface
I have a property declared on a class: .h @interface myClass : UIView {
i have a custom UIView class,and i have linked my view in IB with
I have a UIView with it's subclass set in interface builder to a UIView
I have a UINavigationController containing an UIViewController initialized with a UIView. The UINavigationController also
I've got a UIViewController and an own class, a subclass of UIView. In my
I have subclass UIView class in a Bounce class with Accelerometer. This Bounce class
I am new to iphone development.I have created a UIview controller class and added
I have a class MyModel with a property datalogEnabled (and other ones, but let's
I have a UIView custom class and the object created by this class has

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.