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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:46:57+00:00 2026-06-05T07:46:57+00:00

I have two classes, a View and a ViewController. The View creates a button

  • 0

I have two classes, a View and a ViewController. The View creates a button as follows:

_button = [[UIButton alloc] initWithFrame:CGRectMake(50, 0, buttonImage.size.width, buttonImage.size.height)];
[_button setImage:buttonImage forState:UIControlStateNormal];
[_button setImage:[UIImage imageNamed:@"btn_learn_focus_pad"] forState:UIControlEventTouchUpInside];
[_button addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
[_someView addSubview:_button];

In the ViewController, after I instantiated the view in loadView, I add a selector to is as follows:

[view.button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];

The selector is not being called. I tried to NSLog in the ViewController the button’s position and it printed out a zero. I suspect that ARC is releasing the button. _button however, is a strong pointer (@property). So I am not sure why this is happening.

How do I get around this?

  • 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-05T07:46:58+00:00Added an answer on June 5, 2026 at 7:46 am

    You are not utilizing the proper getter/setter methods generated by the property synthesis. If you just change the first line to:

    self.button = [[UIButton alloc] initWithFrame:CGRectMake(50, 0, buttonImage.size.width, buttonImage.size.height)];
    

    It will properly retain the pointer

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

Sidebar

Related Questions

I have two view controller classes in my application delegate. I can change from
I have two classes ' Product ' and ' Ingredient '; In my view
i have made two view classes in first view class i am making more
I have two classes of View Controllers.... View 1 View 2 View 1 @interface
I have two classes. In my first class i have table view which contains
In my Android application, I have two activity classes. I have a button on
I have two classes which need to be in same xml file. The way
I have two classes: class Translation(models.Model): content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() object =
I have two classes defined like public class PostleitzahlList : ObservableCollection<Postleitzahl> { } public
I have two classes declared in C# code: public class A { public static

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.