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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:50:12+00:00 2026-06-11T12:50:12+00:00

I am using a custom view and there is a UIButton in it but

  • 0

I am using a custom view and there is a UIButton in it but it is not working. Of course the button is inside the custom view. It’s driving me crazy. I tried by self.isUserInteractionEnabled = YES;, but getting an error “No setter method ‘setIsUserInteractionEnabled:’ for assignment”. Can anyone help…

My header file…

#import <Foundation/Foundation.h>
#import "Clone.h"

@class UICloneInfoView;

@interface UICloneInfoView : UIImageView
{
    Clone *clone;    
}

@property(nonatomic, retain) Clone *clone;
@property(nonatomic, retain) UIButton *button;
@property(nonatomic, retain) UILabel *infoLabel;

// set a clone to show information on the bar
- (void)setClone:(Clone *)aClone;

@end

Here is the .m file…

#import "UICloneInfoView.h"

#define DEFAULT_HEIGHT_VIEW     90.0f
#define DEFAULT_WIDTH_VIEW      819.0f
#define DEFAULT_BUTTON_SIZE     40.0f

@implementation UICloneInfoView
@synthesize clone = _clone;
@synthesize button = _button;
@synthesize infoLabel = _infoLabel;

- (id)initWithImage:(UIImage *)image
{
    self = [super initWithImage:image];

    if (self) {
        // init somthing

        // init info label
        _infoLabel = [[UILabel alloc] initWithFrame:CGRectMake(10.0f, 5.0f, DEFAULT_WIDTH_VIEW - 80.0f, DEFAULT_HEIGHT_VIEW)];
        _infoLabel.backgroundColor = [UIColor clearColor];
        _infoLabel.font = [UIFont boldSystemFontOfSize:13.0f];
        _infoLabel.lineBreakMode = UILineBreakModeCharacterWrap;
        _infoLabel.numberOfLines = 3;

        // init button
        _button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        _button.frame = CGRectMake(_infoLabel.frame.origin.x + _infoLabel.frame.size.width + 10.0f, (self.frame.size.height/2), DEFAULT_BUTTON_SIZE, DEFAULT_BUTTON_SIZE);
        [_button setTitle:@"1" forState:UIControlStateNormal];
        [_button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_button];
    }

    return self;
}

- (void)setClone:(Clone *)aClone
{
    _clone = aClone;

    // set label text
    _infoLabel.text = [NSString stringWithFormat:@"Start Line: %d\tEnd Line: %d\t nLines: %d\tpcid: %d\nFile: %@", _clone.startLine, _clone.endLine, _clone.endLine - _clone.startLine + 1, _clone.pcid, _clone.sourcePath];

    // adjust the label with new height    
    CGSize expectedLabelSize = [_infoLabel.text sizeWithFont:_infoLabel.font constrainedToSize:_infoLabel.frame.size lineBreakMode:_infoLabel.lineBreakMode];
    CGRect newFrame = _infoLabel.frame;
    newFrame.size.height = expectedLabelSize.height;
    _infoLabel.frame = newFrame;

    // add _infoLabel to view
    [self addSubview:_infoLabel];
}

- (void)buttonAction:(id)sender
{
    NSLog(@"%@", ((UIButton*)sender).titleLabel.text);
}

@end

Here is a snapshot
enter image description here

Thanks in advance.

  • 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-11T12:50:14+00:00Added an answer on June 11, 2026 at 12:50 pm

    UIImageView has userInteractionEnabled set to NO by default. You are adding the button as a subview to the image view. You should set it to YES.

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

Sidebar

Related Questions

Is there a right/wrong approach for creating a Custom view using code or IB?
I am using custom row view in ListView widget. I am having getView method
I want to manipulate HTML using a custom view engine like this: protected override
Right now I am using a custom list view and I am inflating an
In my custom view I'm looking into using Canvas.getClipBounds() to optimize my onDraw method
i am using custom checkbox buttons in my table view and want to save
I am using apple's custom table view cell code and modifying the drawRect code
I'm using Drupal 6. I have a custom view that needs to be filtered
In my iOS application, I'm using custom NavigationItem (added to root view from Nib
So I created a custom text view using core graphics and have it conformed

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.