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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:21:57+00:00 2026-06-04T07:21:57+00:00

I am learning iOS. I m using Xcode 4.3.2 , and i have created

  • 0

I am learning iOS. I m using Xcode 4.3.2 , and i have created a button, and in the callback, i have used the following code.

1) Created single view application
2) creating a new view -> newV
3) creating a button but;
4) adding but as a subview of newV.
5) adding newV as a subview of main view.

-(IBAction) submitButtonPressed:(id)sender
{
    NSLog (@" Submit Button is pressed ");
    UIView *newV = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    newV.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];

    UIButton *but = [[UIButton alloc] init];
    [but setTitle:@"SubView" forState:UIControlStateNormal];
    [newV addSubview:but];
    [self.view addSubview:newV];

}

But the problem i get is, only the view viewV is shown, but button is not shown. How to resolve this issue ?

  • 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-04T07:21:58+00:00Added an answer on June 4, 2026 at 7:21 am

    When you created the button, you didn’t provide a frame. Try using:

    UIButton* but = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, buttonWidth, buttonHeight)];
    

    When you created the button, it was of zero size, so you couldn’t see it.

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

Sidebar

Related Questions

Learning xml, Can anyone help me? I have following XML code: **<book lang=en>name of
I am learning iOS and I have written a simple iPhone app using iOS
I'm just getting started learning CoreData for iOS and have written some exploratory code
I'm learning iOS development and would really like to look at an example application
I am learning to develop iPhone applications using iOS 5. I am trying to
I am just starting climbing the Objective C learning curve (using Nerd Ranch iOS
I have been learning iOS development for a few days now. At this moment,
I am very new to iOS Programming and have been learning for only a
I am currently using IOS SDK 4.0.2 and learning how to do UIAutomation. Unfortunately
I am just learning objective-C, and have a book with code like this: NSArray

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.