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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:12:56+00:00 2026-05-28T04:12:56+00:00

I am trying to create UIViewController programmatically for ModalView presentation on the main window

  • 0

I am trying to create UIViewController programmatically for ModalView presentation on the main window of the application and in this UIViewController on top i have is Navigation bar with done button to dismiss the view and below the navigation bar it has UITextView.

So my question is that the UITextview which i want to create below the navigation bar will come in the ViewdidLoad Method or i m doing right to show separate medthod to setup textview .

In the Infoviewcontroller.h file have following code:

#import <UIKit/UIKit.h>
@interface Infoviewcontroller : UIViewController <UITextViewDelegate>{
    UITextView *textView;
}
@property (nonatomic, retain) UITextView *textView;
@property (nonatomic, assign) UINavigationBar *navBar;
@end

Then in the infoviewcontroller.m file have the following code:

#import "Infoviewcontroller.h"
@implementation Infoviewcontroller
@synthesize textView;
@synthesize navBar;

-(void)dealloc{
   [textView release];
   [navBar release];
   [super dealloc];
}

-(void)setupTextView {
    self.textView = [[[UITextView alloc] initWithFrame:self.view.frame] autorelease];
    self.textView.textColor = [UIColor redColor];
    self.textView.font = [UIFont fontWithName:@"System Bold" size:13];
    self.textView.delegate = self;
    self.textView.backgroundColor = [UIColor whiteColor];
    self.textView.textAlignment =  UITextAlignmentCenter;
    self.textView.text = @"This is UITextView\nThis is UITextView\nThis is UITextView\nThis is UITextView"; 
    [self.view addSubview: self.textView];    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    navBar = [[UINavigationBar alloc] init];
    UINavigationItem *navItem = [[[UINavigationItem alloc]         initWithTitle:@"ModalViewControllerTest"] autorelease];
    UIBarButtonItem *done = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissView:)] autorelease];
    navItem.rightBarButtonItem = done;
    navBar.items = [NSArray arrayWithObject:navItem];
    [self.view addSubview:navBar];
}
  • 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-28T04:12:56+00:00Added an answer on May 28, 2026 at 4:12 am

    Regarding creation of UINavigationBar programmatically, I found following blog post helpful http://cps.liridesce.com/?p=100. Example overrides loadView rather than viewDidLoad method, but I think in your case using viewDidLoad should have the same effect.

    I would also add viewDidUnload where I would set to nil navBar and textView properties.

    I’m not quite sure why you need separate setupTextView method, unless you are calling it from different places of your UIViewController. I would just keep everything together in viewDidUnload.

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

Sidebar

Related Questions

I have been trying to create a navigation bar back button. Here is my
I'm trying to create a UITextView in my Main UIViewController when a UIControlEventTouchUpInside happens
Trying to create a QtRuby application, I get the following error: /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2144: [BUG] Segmentation
Trying to create a small monitor application that displays current internet usage as percentage
so I have subclassed a UIViewController that I create. The question is, is there
I'm trying to make my app feel more customized with a shaded navigation bar.
I'm trying to create a custom editor for my UIViewController. It was suggested that
I'm trying to create a UIViewController that draws a layer and it works fine
I'm trying to create a basic navigation app using UINavigationController as root container for
I'm trying to create an application that allows users to go through a set

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.