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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:27:02+00:00 2026-06-02T03:27:02+00:00

im doing a test for subclassing uiControl, but it is not working yet, here

  • 0

im doing a test for subclassing uiControl, but it is not working yet,

here my code:

MainVC.m::

- (void)viewDidLoad
{
    [super viewDidLoad];

    TesteaContol *tt = [[[TesteaContol alloc]initWithFrame:CGRectMake(20, 20, 80, 30)]autorelease];
    [tt addTarget:self action:@selector(ttActiono:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:tt];
}

- (void)ttActiono:(TesteaContol*)message
{
    NSLog(@"proyection");
}

TesteaContol.h

@interface TesteaContol : UIControl

TesteaControl.m

#import "TesteaContol.h"

    @implementation TesteaContol

    - (id)initWithFrame:(CGRect)frame
    {
        self = [super initWithFrame:frame];
        if (self) {
            // Initialization code

            NSLog(@"cao");

            UIButton *vacas = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            [vacas setTitle:@"pingus" forState:UIControlStateNormal];   ;
            vacas.titleLabel.textColor = [UIColor blackColor];

            vacas.frame = CGRectMake(0, 0, 80, 40);
            [vacas addTarget:self action:@selector(vacasPressed:) forControlEvents:UIControlStateNormal];

            [self addSubview:vacas];
        }
        return self;
    }


    - (void) vacasPressed:(id) sender
    {
        NSLog(@"vacanio");

        [self sendActionsForControlEvents:UIControlEventTouchUpInside];

    }

so I am testing with a uiButton, i see the button, but is not responding to the touches,

what im i missing?

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-06-02T03:27:03+00:00Added an answer on June 2, 2026 at 3:27 am

    There is a problem here:

    [vacas addTarget:self action:@selector(vacasPressed:) 
        forControlEvents:UIControlStateNormal];
    

    The “forControlEvents” part should be of type UIControlEvents which UIControlStateNormal is not. For a regular button, you want to replace UIControlStateNormal with UIControlEventTouchUpInside:

    [vacas addTarget:self action:@selector(vacasPressed:)
        forControlEvents:UIControlEventTouchUpInside];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is a test framework to show what I am doing: create a new
Here's what I'm doing atm: test = { 'd' => 20, 'b' => 40,
I am doing some test using WordDelimiterFilter in Solr but it doesn't preserve the
after doing some test-code for this link : Is it safe to call temporary
I know that one can define an 'expected' exception in JUnit, doing: @Test(expect=MyException.class) public
im doing a little test to check whether the user is away (unactive) or
I am doing the below test to try and learn more about LINQ to
I am doing a unit test on a class that uses the unity dependency
I was doing a little test to try Ruby's pty and I can't get
I'm doing a simple test using the wakoopa (software tracking) api . Typing the

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.