iOS 중간에서 UINavagationController를 적용합니다. (Objective-C)
2691 단어 iOSObjective-C
ViewController.m
#import "ViewController.h"
#import "NextViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor grayColor];
UILabel *label= [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMidX(self.view.bounds)-130, CGRectGetMidY(self.view.bounds)-20, 260, 40)];
label.text = @"最初のビューコントローラーさん";
label.textColor = [UIColor whiteColor];
[self.view addSubview:label];
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
NextViewController *next = [[NextViewController alloc]init];
[self presentViewController:next animated:YES completion:nil];
}
@end
NextViewController.m
#import "NextViewController.h"
#import "ThirdViewController.h"
@interface NextViewController ()
@end
@implementation NextViewController
- (void)viewDidLoad {
self.view.backgroundColor = [UIColor yellowColor];
UILabel *label= [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMidX(self.view.bounds)-140, CGRectGetMidY(self.view.bounds)-20, 280, 40)];
label.text = @"ネクストビューコントローラーさん";
label.textColor = [UIColor blackColor];
[self.view addSubview:label];
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
ThirdViewController *third = [[ThirdViewController alloc]init];
UINavigationController *nv = [[UINavigationController alloc]initWithRootViewController:third];
[self presentViewController:nv animated:YES completion:nil];
}
@end
ThirdViewController.m
#import "ThirdViewController.h"
@interface ThirdViewController ()
@end
@implementation ThirdViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor greenColor];
self.title = @"サードビューコントローラーさん";
// Do any additional setup after loading the view.
}
@end
Reference
이 문제에 관하여(iOS 중간에서 UINavagationController를 적용합니다. (Objective-C)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/masumi5177/items/78e2e8be5650c8a79ff6텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)