一、簡單介紹
xib和storyboard的比較,一個輕量級一個重量級。
共同點:
都用來描述軟件界面
都用Interface Builder工具來編輯
不同點:
Xib是輕量級的,用來描述局部的UI界面
Storyboard是重量級的,用來描述整個軟件的多個界面,并且能展示多個界面之間的跳轉(zhuǎn)關(guān)系
二、簡單使用
說實話,經(jīng)常逛大牛的博客的確是一件傷腦經(jīng)的事情(我先申明人家寫的非常好,只是長篇大論對于我急忙找出自己滿意的地方的過程是一件痛苦的過程),我不知道大家怎么想,有的東西有時候很簡單,不需要細(xì)說的時候,有時候說的太細(xì)了反而感覺啰嗦。哈哈!廢話少說,至于Xib怎么建立,怎么命名,我就不多說了,我覺得這個沒啥技術(shù)水平。下面僅僅將寫的很菜的Demo展示下!希望大家不要打我啊!哈哈!
三、示例代碼
--tableViewCell關(guān)聯(lián)Xib的代碼

--下面是ImageView(美女圖片)、describtion(美女一枚,求帶走)和name(Label)的的Xib布局。

.m控制器里的代碼實現(xiàn)
//Created bysyc on 16/3/25.
//Copyright ? 2016年YS. All rights reserved.
#import"TableViewController.h"
#import"TableViewCell.h"
@interfaceTableViewController()
@property(strong,nonatomic)IBOutletUITableView*tableView;
@end
@implementationTableViewController
- (void)viewDidLoad {
[superviewDidLoad];
self.tableView.rowHeight=100;
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - table view dataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView*)tableView {
? ?return ?1;
}
- (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section {
? ?return ? 4;
}
- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath {
TableViewCell*cell = [tableViewdequeueReusableCellWithIdentifier:@"cell"];
if(cell ==nil) {
NSArray*nibs =[[NSBundlemainBundle]loadNibNamed:@"TableViewController"owner:niloptions:nil];
cell = [nibslastObject];
cell.name.text=@"小明";
}
cell.backgroundColor= [UIColorclearColor];
returncell;
}
#pragma mark - table view delegate
- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath {
//kTipAlert(@"<%ld> selected...", indexPath.row);
}
以下是截圖代碼(功能和上面一樣)


就廢話這么多了吧!哈哈!感覺對自己用用的可以看看哦!咋們下次不見不散?。◤U話!下次必須見的!是吧?Smile)