IOS uicontroller

来源:互联网 发布:ubuntu环境变量bashrc 编辑:程序博客网 时间:2024/05/22 05:09
#import "AppDelegate.h"#import "mainViewController.h"@interface AppDelegate ()            @end@implementation AppDelegate            - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];    // Override point for customization after application launch.    self.window.backgroundColor = [UIColor redColor];        mainViewController *mvc = [[mainViewController alloc]init];    self.window.rootViewController = mvc;            [self.window makeKeyAndVisible];    return YES;}

#import "mainViewController.h"#import "subViewController.h"@interface mainViewController ()@end@implementation mainViewController- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];    if (self) {        // Custom initialization    }    return self;}- (void)viewDidLoad{    [super viewDidLoad];    self.navigationController.transitionCoordinator ==NO;    self.view.backgroundColor = [UIColor orangeColor];    NSLog(@"x = %f",self.view.frame.origin.x);    NSLog(@"y = %f",self.view.frame.origin.y);    NSLog(@"w = %f",self.view.frame.size.width);    NSLog(@"h = %f",self.view.frame.size.height);     UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];    btn.frame = CGRectMake(10, 30, 300, 30);    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];    btn.backgroundColor = [UIColor whiteColor];    [btn setTitle:@"模式对话窗体跳转" forState:UIControlStateNormal];    [btn addTarget:self action:@selector(btnclick) forControlEvents:UIControlEventTouchUpInside];    [self.view addSubview:btn];        UITextView *textview = [[UITextView alloc]initWithFrame:CGRectMake(10, 70, 300, 50)];    textview.text = @"欢迎您";    textview.backgroundColor = [UIColor whiteColor];    textview.textColor = [UIColor blackColor];    [self.view addSubview:textview];    // Do any additional setup after loading the view.}-(void)btnclick{    subViewController *svc = [[subViewController alloc]init];    svc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;    [self presentViewController:svc animated:YES completion:^{}];}- (void)didReceiveMemoryWarning{    [super didReceiveMemoryWarning];    // Dispose of any resources that can be recreated.}-(void)loadView{    [super loadView];}-(void)viewWillAppear:(BOOL)animated{}/*#pragma mark - Navigation// In a storyboard-based application, you will often want to do a little preparation before navigation- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{    // Get the new view controller using [segue destinationViewController].    // Pass the selected object to the new view controller.}*/@end

#import "subViewController.h"#import "mainViewController.h"@interface subViewController ()@end@implementation subViewController- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];    if (self) {        // Custom initialization    }    return self;}- (void)viewDidLoad{    [super viewDidLoad];    self.view.backgroundColor = [UIColor blueColor];    UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];    btn.frame = CGRectMake(10, 30, 300, 30);    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];    btn.backgroundColor = [UIColor whiteColor];    [btn setTitle:@"关闭对话窗体" forState:UIControlStateNormal];    [btn addTarget:self action:@selector(btnclick) forControlEvents:UIControlEventTouchUpInside];    [self.view addSubview:btn];           // Do any additional setup after loading the view.}-(void)btnclick{    mainViewController *mvc = [[mainViewController alloc]init];    [self presentViewController:mvc animated:YES completion:^{}];   // [self dismissViewControllerAnimated:YES completion:^{ }];}- (void)didReceiveMemoryWarning{    [super didReceiveMemoryWarning];    // Dispose of any resources that can be recreated.}/*#pragma mark - Navigation// In a storyboard-based application, you will often want to do a little preparation before navigation- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{    // Get the new view controller using [segue destinationViewController].    // Pass the selected object to the new view controller.}*/@end

0 0
原创粉丝点击