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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:46:46+00:00 2026-05-18T01:46:46+00:00

Can some explain how to properly subclass a UIViewController and then load it into

  • 0

Can some explain how to properly subclass a UIViewController and then load it into the window without using a nib.

Do i need to set the view and when do I do it? loadView?

My app crashes when I use my customUIViewController sub-class. Everything loads up find until I click a button and it compains about “Bad Access”

GettingStarted *vc = [[GettingStarted alloc] init];


UISplitViewController *split = self.splitViewController;
NSArray *vcArray = split.viewControllers;

NSLog(@"viewcontroll cout:%d", vcArray.count);

    // this line of code crashes my app. I fi comment it out everything works fine
UINavigationController *detailViewController = (UINavigationController*)[vcArray objectAtIndex:1];
//


detailViewController  pushViewController:vc animated:YES];


[vc release];

GettingStarted.m

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];

[self.navigationItem setHidesBackButton:YES animated:YES];

//UIView *baseView = [[UIView alloc] init];

[[self navigationItem] setTitle:@"Getting Started"];

UIImageView *noUsersIV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"no_users.png"]];

[noUsersIV setFrame:CGRectMake(0.0f, 0.0f, 466, 961.0f)];
[noUsersIV setHidden:NO];
[noUsersIV setTag:1006];
[[self view] addSubview:noUsersIV];
[noUsersIV release];


UIButton *btnAddUser = [UIButton buttonWithType:UIButtonTypeCustom];
[btnAddUser setImage:[UIImage imageNamed:@"no_users_button_standard.png"] forState:UIControlStateNormal];
[btnAddUser setImage:[UIImage imageNamed:@"no_users_button_activated.png"] forState:UIControlStateSelected];
[btnAddUser addTarget:self action:@selector(addUser:) forControlEvents:UIControlEventTouchUpInside];
[btnAddUser setFrame:CGRectMake(0, 428,466, 124)];


[[self view] addSubview:btnAddUser];

[btnAddUser release];


//self.view = baseView;

//[baseView release];

}
  • 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-18T01:46:47+00:00Added an answer on May 18, 2026 at 1:46 am

    What is the result of your log message? Are you sure you have >=2 objects in that array?

    Does the crash happen with pushNavigationController on the callstack, or does the crash happen later?

    You also don’t need to release split, vcArray, or detailViewController. The [detailViewController release] will certainly cause a crash. The others would cause crashes later.

    When functions return objects unless you are calling retain on it, or the function returning the object is named alloc/copy/create, the object will be autoreleased so you don’t need to release it.

    someArray = [NSArray arrayWithObjects:...]; // no need to release
    someArray = someClass.array; // no need to release
    
    someArray = [[NSArray alloc] init]; // alloc, need to release
    someArray = [[NSArray arrayWithObjects:...] retain]; // retained, need to release
    

    The reason you would call retain in the second example above is if you wish to use the object outside of this function. If you do you need to retain it, if not it will be auto-released later.

    Update: You have a similar problem where you are adding the button.

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

Sidebar

Related Questions

Can some one explain to me the difference between categories and inheritance in Objective
How to pass parameters to [WebMethod] in Asp.Net(C#) ? Can some one please explain
Can anyone explain the difference between the types mentioned above and some sample usage
Can anyone explain the use of ^ operator in java with some examples?
What is meant by object serialization? Can you please explain it with some examples?
Can some one specify the windows API, one need to use in order to
Can some one post an example of using syslog outputter for log4r, I am
How to read data from Bar Code Scanner in .net windows application? Can some
I can see some options available: 1) Use PEAR's POP3 class --> tried it,
I have an Interface called IStep that can do some computation (See Execution in

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.