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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:35:00+00:00 2026-05-28T07:35:00+00:00

First ViewController.xib contains 4 views (without UINavigationController in xib). ViewController.h – were here …

  • 0

First ViewController.xib contains 4 views (without UINavigationController in xib).

  1. “ViewController.h” – were here …
  2. “GlavView.h” – got here …

How to go back to 1 (ViewController.h)?

// Methods

- (IBAction) iBM_GlavView:(id)sender;
- (void) iDM_GlavView;

These methods are not available in GlavView.m if I did not tie the selector button to the First Responder, but they are available in ViewController.m

If you use Interface Builder, then it works, but I do not want to use Interface Builder, and without it, to reach out to ViewController, I do not know.

Thank you for any help!

Here is part of the application code:

————— AppDelegate.h

//
//  AppDelegate.h
//
//


#import <UIKit/UIKit.h>

@class ViewController;

@interface AppDelegate : NSObject <UIApplicationDelegate> //UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@property (strong, nonatomic) ViewController *viewController;

@end

————— ViewController.h

//
//  ViewController.h
//

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController{
    UINavigationController *navigationController;
}


@property (retain, nonatomic) IBOutlet UINavigationController *navigationController;


- (IBAction) iBM_GlavView:(id)sender;
- (void) iDM_GlavView;

@end

————— ViewController.m

//
//  ViewController.m
//  SeifNote
//
//  Created by Saveliy Severniy on 19.01.12.
//  Copyright (c) 2012 Saveliy Severniy. All rights reserved.
//

#import "ViewController.h"
#import "GlavView.h"

@implementation ViewController

@synthesize navigationController;

- (void)viewDidLoad
{
    [super viewDidLoad];

    if( isLogin )
    {
        // Ok
        [self iDM_GlavView];
    }
    else
    {

        [self.view addSubview:self.viewEnterPass];
    }
}

- (IBAction)iBM_GlavView:(id)sender{

    if (self.navigationController == nil) {

        //navigationController is declared as: UINavigationController * navigationController;
        navigationController = [[UINavigationController alloc] init];

        GlavView *myOptions = [[GlavView alloc] initWithNibName:@"GlavView" bundle:nil];

        [navigationController pushViewController:myOptions animated:NO];
        [myOptions release];

    }

    [self.view addSubview:navigationController.view]; // From this point begins the work UINavigationController in a new view

}




- (void) iDM_GlavView {

    if (self.navigationController == nil) {

        // navigationController is declared as: UINavigationController *optionsRootController;
        navigationController = [[UINavigationController alloc] init];

        GlavView *myOptions = [[GlavView alloc] initWithNibName:@"GlavView" bundle:nil];

        [navigationController pushViewController:myOptions animated:NO];
        [myOptions release];

    }

    [self.view addSubview:navigationController.view];
}

————— GlavView.h

//
//  GlavView.h
//

#import <UIKit/UIKit.h>

@interface GlavView : UITableViewController {
    UIToolbar *toolbar;
    IBOutlet UIBarButtonItem *addButtonItem;
}

@property (nonatomic, retain) UIBarButtonItem* addButtonItem;

@end

————— GlavView.m

//
//  GlavView.m
//

#import "GlavView.h"

@implementation GlavView

@synthesize addButtonItem;


- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

    //  is declared as: UIBarButtonItem *addButtonItem;
    self.navigationItem.rightBarButtonItem = self.addButtonItem;
}


- (void)viewWillAppear:(BOOL)animated {

    [super viewWillAppear:animated];

    //Initialize the toolbar
    toolbar = [[UIToolbar alloc] init];
    toolbar.barStyle = UIBarStyleDefault;

    //Set the toolbar to fit the width of the app.
    [toolbar sizeToFit];

    //Caclulate the height of the toolbar
    CGFloat toolbarHeight = [toolbar frame].size.height;

    //Get the bounds of the parent view
    CGRect rootViewBounds = self.parentViewController.view.bounds;

    //Get the height of the parent view.
    CGFloat rootViewHeight = CGRectGetHeight(rootViewBounds);

    //Get the width of the parent view,
    CGFloat rootViewWidth = CGRectGetWidth(rootViewBounds);

    //Create a rectangle for the toolbar
    CGRect rectArea = CGRectMake(0, rootViewHeight - toolbarHeight, rootViewWidth, toolbarHeight);

    //Reposition and resize the receiver
    [toolbar setFrame:rectArea];


    //Create a button
    UIBarButtonItem *testButton = [[UIBarButtonItem alloc] 
                                   initWithTitle:@"Del" style:UIBarButtonItemStyleBordered target:self action:@selector(test_clicked:)];

    [toolbar setItems:[NSArray arrayWithObjects:testButton,nil]];

    [testButton release];

    //Add the toolbar as a subview to the navigation controller.
    [self.navigationController.view addSubview:toolbar];

    //Reload the table view
    [self.tableView reloadData];
}


- (void) test_clicked:(id)sender {

    // iBM_GlavView is declared in ViewController.h

    [??? iBM_GlavView]; // How to get out of here (GlavView) and return (ViewController)?
}
  • 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-28T07:35:01+00:00Added an answer on May 28, 2026 at 7:35 am

    iSavaDevRu, see navigationController methods

    this method is for you 🙂

    NSNotificationCenter удобная штука
    смотри делай так

    //добовляем из кода метод к нажатие кнопки
    
        [button addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside];
    -(void)buttonPressed {
    [[NSNotificationCenter defaultCenter] postNotificationName:@"BUTTONPRESSED" object:nil];
    }
    
    //а потом добавляем в нашем контороллере чтоб вызывался наш метод при вывидение этой нотификаций
    -(void)viewDidLoad {
    [super viewDidLoad];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(IBM_DelPass:) name:@"BUTTONPRESSED" object:nil];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my first xib contains a ScrollView with a springboard like interface in MainWindow.xib: -
I have an application with UITabBarController, where the first tab contains a ViewController of
Here is the layout of my app. ApplicationName LoginViewController.h LoginViewController.m LoginView.xib AppDelegate.h AppDelegate.m ViewController.h
I've got a project setup using a Storyboard that contains a UITabViewController as the
I have a tabBarController xib. I've set the first item's class to a view
I have a viewcontroller(say A). I am pushing some viewcontrollers over the first viewcontroller(A).
I am trying to initialize a ViewController from another. Here is the code written
I am making a view based application in which the first controller is viewcontroller
There are 4 items on MyViewController.xib window: File's Owner (of type MyViewController) First Responder
i have created a project which has different xib viewcontrollers.In first view am selecting

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.