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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:33:17+00:00 2026-06-11T03:33:17+00:00

I have a custom subclassed uiview I created to display in-app notifications. I can

  • 0

I have a custom subclassed uiview I created to display in-app notifications.
I can call the view just fine, but am having problems dismissing it using a uibutton (embedded in the custom view)

When the button is pressed, the app crashes and I get this error:

UPDATE – Fixed the above issue, but now only the button dismisses, and not the actual view. See updated code below.

-(id)initWithMessage:(NSString *)message{
    self = [super initWithFrame:CGRectMake(0, -70, 320, 60)];
    if (self) {        
        //Add Image
        UIImage *image = [UIImage imageNamed:@"notice-drop-down"];
        UIImageView *background = [[UIImageView alloc] initWithImage:image];
        [self addSubview:background];

        //Add Label
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, self.frame.size.height/2-25, 300, 50)];
        [label setBackgroundColor:[UIColor clearColor]];
        [label setTextColor:[UIColor blackColor]];
        [label setText:message];
        label.numberOfLines = 0;
        [label setFont:[UIFont fontWithName:@"Hand of Sean" size:16]];
        //NSLog(@"FONT FAMILIES\n%@",[UIFont familyNames]);


        [self addSubview:label];

        //Add Close Button
        UIButton *closeButton = [[UIButton alloc] initWithFrame:CGRectMake(280, self.frame.size.height/2-15, 30, 30)];
        UIImage *closeImage = [UIImage imageNamed:@"notice-close"];
        [closeButton setImage:closeImage forState:UIControlStateNormal];
        [closeButton addTarget:self action:@selector(closeNoticeDropDown:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:closeButton];

        //Animate In
        [UIView animateWithDuration:1
                              delay:0
                            options: UIViewAnimationCurveEaseIn
                         animations:^{
                             self.frame = CGRectMake(0,70,320,60);
                         }
                         completion:nil
         ];
    }
    return self;
}

-(void)closeNoticeDropDown:(id)self{
    NoticeDropDown *notice = (NoticeDropDown *)self;
    NSLog(@"Frame: %f",notice.frame.size.width);
    //Animate In
    [UIView animateWithDuration:1
                          delay:0
                        options: UIViewAnimationCurveEaseOut
                     animations:^{
                         notice.frame = CGRectMake(0,-70,320,60);
                     }
                     completion:^(BOOL finished){
                         [notice removeFromSuperview];
                         //notice = nil;
                     }
     ];
}

View call from another view controller:

noticeDropDown = [[NoticeDropDown alloc] initWithMessage:message];
[self.view insertSubview:noticeDropDown belowSubview:hudContainerTop];
  • 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-11T03:33:19+00:00Added an answer on June 11, 2026 at 3:33 am

    You have declared your method to be a class method but are sending the message to an instance. If you want it to be a class method still, pass [NoticeDropDown class] as the target parameter to your addTarget:action:forControlEvemts: method. Otherwise replace the “+” with a “-” in the method declaration.

    Also- when UIControl actions have sender parameters it will send the control as the sender – so you will get a UIButton instead of your view.

    My recommendation is to change your action to an instance method and replace “sender” with “self”.

    I apologize for formatting I’m posting from my phone. I’ll try to fix when back at a computer.

    EDIT:

    Change your updated method like so:

    -(void)closeNoticeDropDown:(id)sender{
        NSLog(@"Frame: %f",notice.frame.size.width);
        //Animate In
        [UIView animateWithDuration:1
                              delay:0
                            options: UIViewAnimationCurveEaseOut
                         animations:^{
                             self.frame = CGRectMake(0,-70,320,60);
                         }
                         completion:^(BOOL finished){
                             [self removeFromSuperview];
                         }
         ];
    }
    

    You don’t need to pass self into a method, it always exists.

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

Sidebar

Related Questions

i have created a custom view class which is a subclass of UIview class
Hope you can help. I have created my own Custom UIView and I'm trying
I currently have a simple iPhone app that loads a custom subclass of UIView.
I have created a custom subclass of UIView for an interface element that I
I have subclassed UIView and created a NIB that controls the main logic for
I have subclassed UIView and provided my own drawRect, which works fine. However I
I have created a UIView subclass in order to implement a custom drawRect method.
I have created a custom UIView that I would like to use on multiple
I have subclassed a control in C# WinForms, and am custom drawing text in
I have created a custom subclass of UITableViewCell. There, I allow the user to

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.