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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:51:03+00:00 2026-05-13T22:51:03+00:00

i’ve the following code for button creation and on action of button , i’m

  • 0

i’ve the following code for button creation and on action of button , i’m calling buildUI method

CGRect cgRct = CGRectMake(10 ,30 ,400, 320); //define size and position of view 
subMainView_G_obj = [[UIView alloc] initWithFrame:cgRct]; //initilize the view 
subMainView_G_obj.autoresizesSubviews = YES;  

//set view property ov controller to the newly created view
// create Button's for modules in array (UIButtonTypeRoundedRect)
UIButton_G_obj = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain]; 
UIButton_G_obj.frame = CGRectMake(100,30,100,50);
[UIButton_G_obj setTitle:@"UI" forState:UIControlStateNormal];
UIButton_G_obj.backgroundColor = [UIColor clearColor];
[subMainView_G_obj  addSubview:UIButton_G_obj];
//[UIButton_G_obj setEnabled:TRUE];
[UIButton_G_obj addTarget:subMainView_G_obj action:@selector(buildUIWorkArea) forControlEvents:UIControlEventTouchUpInside];

 [mainView_G_obj addSubview:subMainView_G_obj];

}
-(void)buildUIWorkArea
{
//UIView* uiWorkAreaView_G_obj;
[uiWorkAreaView_G_obj clearsContextBeforeDrawing];
CGRect cgRct2 = CGRectMake(0.0, 0.0, 480, 320); //define size and position of View
uiWorkAreaView_G_obj = [[UIView alloc] initWithFrame:cgRct2]; //initilize the view
uiWorkAreaView_G_obj.autoresizesSubviews = YES;

 (UIButtonTypeRoundedRect)buttonUIObj = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain]; 
    buttonUIObj.frame = CGRectMake(100.30,100,50);
    [buttonUIObj setTitle:BUTTON  forState:UIControlStateNormal];
    buttonUIObj.backgroundColor = [UIColor clearColor];
    [uiWorkAreaView_G_obj  addSubview:buttonUIObj];
    [buttonUIObj addTarget:uiWorkAreaView_G_obj action:@selector(showModuleView:) forControlEvents:UIControlEventTouchUpInside];


 [mainView_G_obj clearsContextBeforeDrawing];
 [mainView_G_obj addSubview:uiWorkAreaView_G_obj];

}

On click of button UI which is on UIView uiWorkAreaView_G_obj , it has to create one more button BUTTON on UIView uiWorkAreaView_G_obj.and after placing the button each of there subviews, i’m placing those subviews upon a common mainview_G_obj of type UIView.
But its throwing an exception …….

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIView buildUIWorkArea]:unrecognized selector sent to instance 0x57ca80' 

i didn’t understand why its taking buildUIWorkArea’s return type as UIView , when i’ve declared its return type as void.

plz help.

  • 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-13T22:51:04+00:00Added an answer on May 13, 2026 at 10:51 pm
    [UIButton_G_obj addTarget:subMainView_G_obj action:@selector(buildUIWorkArea)
             forControlEvents:UIControlEventTouchUpInside];
    

    This line means that, when the user touch-up-inside the button, the following function will be called:

    [subMainView_G_obj buildUIWorkArea];
    

    Since subMainView_G_obj is a plain UIView, there’s no -buildUIWorkArea method and thus the error. The return type of -buildUIWorkArea is irrelevant.

    You probably want to send -buildUIWorkArea to self instead:

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

Sidebar

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.