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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:26:49+00:00 2026-05-18T23:26:49+00:00

i have a UIButton made programmatically and i want to add the target and

  • 0

i have a UIButton made programmatically and i want to add the target and the action for that button. i have use method addTarget: action: forControlEvents:

in IOS 4.1 this method is detected, but in 4.2 it didn’t, here is my code

UIButton *moreButton = [[[UIButton alloc] init] autorelease];

float version = [[[UIDevice currentDevice] systemVersion] floatValue]; 
    if(version <= 4.1){
        moreButton = [[UIButton buttonWithType:UIButtonTypeCustom] initWithFrame:CGRectMake(6.3+5*widthSegment, 0.0, widthSegment, heightSegment)];
        [moreButton addTarget:self action:@selector(getPopOverMore:) forControlEvents:UIControlEventTouchUpInside];
    }
    else{
        //version 4.2
        NSLog(@"versi 4.2");
        moreButton = [UIButton buttonWithType:UIButtonTypeCustom];
        moreButton.frame = CGRectMake(6.3+7*widthSegment, 0.0, widthSegment, heightSegment);
        [moreButton addTarget:self action:@selector(getPopOverMore:) forControlEvents:UIControlEventTouchUpInside];
    }

and this is the action method :

- (IBAction)getPopOverMore:(id)sender{

if(moreFileController == nil) {

    moreFileController = [[MoreFilePopController alloc]
                          initWithStyle:UITableViewStylePlain];

    moreFileController.delegate = self;

    moreFilePopOverController = [[UIPopoverController alloc]
                                 initWithContentViewController:moreFileController];
}

CGRect frameMore = CGRectMake(6.3+5*widthSegment, 0.0, widthSegment, heightSegment);


[moreFilePopOverController presentPopoverFromRect:frameMore inView:navBar 
                         permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

}

any body know, what’s wrong here??

  • 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-18T23:26:50+00:00Added an answer on May 18, 2026 at 11:26 pm

    It should work. also the initWithFrame for <=4.1 is unnecessary. i hope you are adding the button as a subview somewhere after this code.

    try placing a breakpoint inside- (IBAction)getPopOverMore:(id)sender{

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

Sidebar

Related Questions

So I have a bunch of UIViews that I made programmatically and placed a
So I have made a custom UIButton and added it to the code and
I have a NSArray of UIImageViews that I want to loop over and quickly
I have made a table and contents some values, I have a button coding
I have UIButton that I set the background image for three states, normal, highlighted,
Suppose I have a method like this - (UIButton *) createButtonAtX:(CGFloat)vX Y:(CGFloat)vY{ //... bla
I have the following example class: Test.h: @interface Test : UIButton { NSString *value;
I have a couple UIViewControllers that I am trying to access an array inside
I have a UISearchBar which is subviewed by another view when a button is
What happens if I release an autoreleased object? Its an autoreleased UIButton I want

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.