UI_UINib
2016-07-13 16:56
357 查看
//
// 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
// 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
相关文章推荐
- GUI - Web前端开发框架
- 评价ui设计作品好坏的八个标准(界面/交互设计研究)
- Jquery ui datepicker设置日期范围,如只能隔3天【实现代码】
- 为Yahoo! UI Extensions Grid增加内置的可编辑器
- Cocos2d-x UI开发之文本类使用实例
- 谈谈对jquery ui tabs 的理解
- 在IE 浏览器中使用 jquery的fadeIn() 效果 英文字符字体加粗
- UI Events 用户界面事件
- 基于Bootstrap的UI扩展 StyleBootstrap
- jQuery UI结合Ajax创建可定制的Web界面
- jquery UI Datepicker时间控件的使用方法(基础版)
- Hallo.js基于jQuery UI所见即所得的Web编辑器
- 基于jQuery UI CSS Framework开发Widget的经验
- jquery ui 1.7 ui.tabs 动态添加与关闭(按钮关闭+双击关闭)
- jquery UI Datepicker时间控件的使用及问题解决
- jQuery UI设置固定日期选择特效代码分享
- Jquery ajax 同步阻塞引起的UI线程阻塞问题
- jQuery UI的Dialog无法提交问题的解决方法
- jQuery ui实现动感的圆角渐变网站导航菜单效果代码
- jquery UI Datepicker时间控件的使用方法(终结版)