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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:51:41+00:00 2026-05-29T19:51:41+00:00

I have a basic subview that slides up 80 from the top of the

  • 0

I have a basic subview that slides up 80 from the top of the screen when a button is pushed. I’ve created another class – AdvancedView – that inherits from UIView. What I would like to do Is first of all, push all the code that’s responsible for creating this subview into it’s own class: AdvancedView. I would then like to somehow set it to where the top 100 of the subview is show showing when the main view loads. I’m going to put a button at on the top showing portion of this subview that will toggle it up and down (I know how to code the button). Here is the code that I need to put into AdvancedView and have the top 100 showing when the main view CalcViewController loads:

#import "CalcViewController.h"
#import "CalculatorBrain.h"
#import "AdvancedView.h"

@property (nonatomic, strong) AdvancedView *myNewView;
@synthesize myNewView = _myNewView;

- (AdvancedView *) myNewView
{
    if (!_myNewView) _myNewView = [[AdvancedView alloc] init];
    return _myNewView;
}

- (IBAction)subView {

    self.myNewView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    self.myNewView.frame = CGRectMake(0,489, 320, 200);
    [self.view addSubview:self.myNewView];
    float bottomYOfDigitBeingDisplayed = 75;

    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [button addTarget:self 
               action:@selector(aMethod:)
     forControlEvents:UIControlEventTouchDown];
    [button setTitle:@"Show View" forState:UIControlStateNormal];
    button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
    [self.myNewView addSubview:button];


    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDelay:0.0];
    [UIView setAnimationDuration: 1.0];
    self.myNewView.frame = CGRectMake(0, bottomYOfDigitBeingDisplayed, 320, 400);
    [UIView commitAnimations];
}
  • 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-29T19:51:43+00:00Added an answer on May 29, 2026 at 7:51 pm

    Your UIView subclass could look like this

    .h

    @interface AdvancedView : UIView {
    
    }
    
    @end
    

    .m

    @implementation AdvancedView
    
    - (id) initWithFrame:(CGRect)rect{
    
       if(self = [super initWithFrame:rect]){
    
           self.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
           UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
           [button addTarget:self 
                       action:@selector(display:)
                       forControlEvents:UIControlEventTouchDown];
           [button setTitle:@"Show View" forState:UIControlStateNormal];
           button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
    
           [self addSubview:button];
    
       }
    
       return self;
    
    
    
    }
    
    - (void) display:(id)sender{
    
        float bottomYOfDigitBeingDisplayed = 75;
    
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDelay:0.0];
        [UIView setAnimationDuration: 1.0];
        self.frame = CGRectMake(0, bottomYOfDigitBeingDisplayed, 320, 400);
        [UIView commitAnimations];
    }
    
    @end
    

    Your UIViewController could look like this

    #import "CalcViewController.h"
    #import "CalculatorBrain.h"
    #import "AdvancedView.h"
    
    @property (nonatomic, strong) AdvancedView *myNewView;
    @synthesize myNewView = _myNewView;
    
    - (AdvancedView *) myNewView
    {
        if (!_myNewView) _myNewView = [[AdvancedView alloc] initWithFrame:
                                                      CGRectMake(0,489, 320, 200);];
        return _myNewView;
    }
    
    - (IBAction)subView {
    
        int advancedTag = 199998;
        self.myNewView.tag = advancedTag;
    
        if(![self.view viewWithTag:advancedTag]){
            [self.view addSubview:self.myNewView];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a basic class that derived subclasses inherit from, it carries the basic
I have basic hello word example of Prime Faces. I have created dynamic web
I have the basic code to rewrite a subdomain to another page. But how
I have a basic has_many :through relationship that is bi-directional: calendars have many calendar_calendar_events
I have some basic questions around understanding fundamentals of Performance testing. I know that
I have a basic div element to represent a message that I show for
I have basic issue that i don't understand, we use HEAT to consume directory
I have basic stored procedure that performs a full text search against 3 columns
I'm working on an old JSP webapp, that has basic 3 presentation areas: top
I have basic code that looks like this: while(inputfileStream.good()) { for(int i = 0;i<levels;i++)

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.