//
// ViewController.m
// UINib
//
// Created by HarrySun on 16/7/13.
// Copyright © 2016年 Mobby. All rights reserved.
//
#import "ViewController.h"
#import "SecondViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
// 使用nib获取View(xib) 这边NibNamed是xib中的Class名字
NSArray *nib = [[NSBundlemainBundle] loadNibNamed:@"MyView"owner:selfoptions:nil];
UIView *tempView = [nibobjectAtIndex:0];
CGRect tempFrame = [[UIScreenmainScreen] bounds];
[tempView setCenter:CGPointMake(tempFrame.size.width / 2, tempFrame.size.height /2)];
[self.viewaddSubview:tempView];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
// 使用nib获取ViewController(xib)SecondViewController是利用xib创建的一个ViewController,上面随便放了一些东西
SecondViewController *secondVC = [[SecondViewControlleralloc]initWithNibName:@"SecondViewController"bundle:nil];
[self.navigationControllerpushViewController:secondVCanimated:YES];
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end