Page 1 skip to page 2
The code is as follows:
1.appdelegate.h
#import <UIKit/UIKit.h>
@interface appdelegate:uiresponder <uiapplicationdelegate>
@property (Strong, nonatomic) uiwindow *window;
@property (Strong, nonatomic)uinavigationcontroller *navigationcontroller;
@end
2. APPDELEGATE.M
#import "AppDelegate.h"
#import "FirstViewController.h"
@interface appdelegate ()
@end
@implementation appdelegate
-(BOOL) application: (uiapplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchoptions {
UIWindow *window = [[uiwindow alloc]initwithframe: [[UIScreen Mainscreen] Bounds]];
Firstviewcontroller *viewcontroller = [[Firstviewcontroller alloc]initwithnibname:@ " Firstviewcontroller " bundle:nil";
_navigationcontroller = [[uinavigationcontroller alloc]initwithrootviewcontroller: Viewcontroller];
[Self. Window addsubview: _navigationcontroller. View];
self. Window. Rootviewcontroller = _navigationcontroller;
Self.window.rootViewController = Viewcontroller;
[self. Window makekeyandvisible];
return YES; return YES;
}
3. FirstViewController.h
#import <UIKit/UIKit.h>
@interface Firstviewcontroller: uiviewcontroller{
}
-(ibaction) Presstosecond: (ID) sender;
@end
4.firstviewcontroller.m
#import "FirstViewController.h"
#import "SecondViewController.h"
#import "AppDelegate.h"
@interface firstviewcontroller ()
@end
@implementation Firstviewcontroller
-(void) Viewdidload {
[Super Viewdidload];
[Self.next addtarget:self Action: @selector (Presstosecond:) forcontrolevents:uicontroleventtouchupinside];
}
-(void) didreceivememorywarning {
[Super didreceivememorywarning];
Dispose of any resources the can be recreated.
}
-(ibaction) Presstosecond: (ID) sender {
Secondviewcontroller *secondview = [[Secondviewcontroller alloc]initwithnibname:@ " Secondviewcontroller " bundle:nil";
page Jump:
Method 1: (Can't pass the value, do not know why??? )
appdelegate *mydelegate = [[uiapplication sharedapplication]delegate];
[MyDelegate. Navigationcontroller pushviewcontroller:secondview animated:YES];
}
@end
This can have the above effect, but if Secondviewcontroller set this controller's Navigationcontroller
Navigationbar will not automatically display the return button, you need to set up in the Secondviewcontroller.
-(void) Viewdidappear: (BOOL) animated{
[Super viewdidappear:animated];
appdelegate *mydelegate = [[uiapplication sharedapplication]delegate];
MyDelegate.navigationController.navigationBarHidden = YES;
self. Navigationcontroller. Navigationbarhidden = YES;
}
Page Jump (Navigaitoncontroller) + with auto-return in IOS