1.appdelegate.h
Define a Uinavigationcontroller
#import <UIKit/UIKit.h>
#import "MainViewController.h"
@interface appdelegate:uiresponder <uiapplicationdelegate>
@property (Strong, nonatomic) uiwindow *window;
@property (Strong, nonatomic) uinavigationcontroller *navigationcotroller;
@end
2.appdelegate.m
#import "AppDelegate.h"
@interface appdelegate ()
@end
@implementation appdelegate
-(BOOL) application: (uiapplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchoptions {
self. Window = [[uiwindow alloc]initwithframe: [[uiscreen mainscreen]bounds]];/ /Instantiate window
Mainviewcontroller *mainviewcontroller = [[Mainviewcontroller alloc]init];// Instantiating a Mainview controller
//Put the Mainview controller in the Navigationcontroller method to make it a root controller
_navigationcotroller = [[uinavigationcontroller alloc] initwithrootviewcontroller: Mainviewcontroller];
[_window addsubview: _navigationcotroller. View ofthe navigation controller loaded in the view];//window
[self. Window makekeyandvisible];//view visible
return YES;
}
3.mainviewcontroller.m
Set the button's page, the button trigger method, call Appdelegate in the navigation controller's Pushviewcontroller method, implement the page jump (automatically generate a return to the health of the page).
Method of button triggering:
[_logonbtn addTarget:self Action:@selector(loginclick:) forcontrolevents: UIControlEventTouchUpInside];
Page Jump:
-(void) Loginclick: (ID) sender{
Logonviewcontroller *logonview = [[Logonviewcontroller alloc]init];
appdelegate *mydelete = [[uiapplication sharedapplication]delegate];
[Mydelete. Navigationcotroller pushviewcontroller:logonview animated:YES];
}
Implement page jump with UIButton (appdelegate +navigationviewcontroller)