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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:28:11+00:00 2026-06-07T13:28:11+00:00

i have one homeview controller where i am adding one subview. that subview is

  • 0

i have one homeview controller where i am adding one subview. that subview is subclass of uiview. but homeview controller not displaying subview.

here is my code.

#import "HomeViewController.h"
@interface HomeViewController : UIViewController {

DetailView *viewDetailFinal;
}
@property (nonatomic, retain) DetailView *viewDetailFinal;


@implementation HomeViewController

@synthesize viewDetailFinal;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    // Custom initialization
    viewDetailFinal = [[DetailView alloc] initWithFrame:CGRectMake(0, 0, 588, 899)];
}
return self;
}

- (void)viewDidLoad
{
   [self.view addSubview:viewDetailFinal];
}

#import "DetailView.h"

@interface DetailView : UIView{

}

-(void) loadView:(NSString *)str;


@implementation DetailView

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

    [self loadView:@"my test text"];
   }
   return self;
}

-(void) loadView:(NSString *)str {
    UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 150, 25)];
    [lbl setFont:[UIFont boldSystemFontOfSize:12.0]];
    [lbl setTextColor:[UIColor blackColor]];
    [lbl setTextAlignment:UITextAlignmentCenter];
    [lbl setBackgroundColor:[UIColor blueColor]];
    [lbl setText:str];
}

Can any one suggest where i am wrong ? Any help will be appreciated.

  • 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-07T13:28:15+00:00Added an answer on June 7, 2026 at 1:28 pm

    First add label to your view like following ….

    -(void) loadView:(NSString *)str {
    UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 150, 25)];
    [lbl setFont:[UIFont boldSystemFontOfSize:12.0]];
    [lbl setTextColor:[UIColor blackColor]];
    [lbl setTextAlignment:UITextAlignmentCenter];
    [lbl setBackgroundColor:[UIColor blueColor]];
    [lbl setText:str];
    
    [self addSubView:lbl];
    }
    

    Then in your view did load method of your Controller class …

    - (void)viewDidLoad
    {
        viewDetailFinal  = [[DetailView  alloc] initWithFrame:CGRectMake(0.0,0.0,320.0,460.0)];
        viewDetailFinal.backgroundColor = [UIColor redColor]; //Just for your verification
        [self.view addSubview:viewDetailFinal];
    }
    

    may this will help you

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

Sidebar

Related Questions

have one time consuming step that flattens a bunch of files. basically i'd like
I have one problem with parsing *.docx document with OpenXML (C#). So, here's my
I have one testing module that I want to use for android testing. I
I have one page design with scrolling eased by jquery using this code: function
I have one dropdownlist in my c# code behind page like `DropDownList dl =
i have one div that contain three div for a part in my website
i have one main relative layout in that i have buttons and in middle
I have one data model 'object' with fields->object_id, object_name. That is: http://localhost:3000/objects/ I have
Have one Doubt In MVC Architecture we can able to pass data from Controller
I have one input inference in Virtuoso Open Source, that was defined from goodrelations

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.