xib和storyboard小谈,
? ?1.共同點:都是用來描述軟件界面
? ?2.不同點
? ? ? Xib是輕量級的,用來描述局部的UI界面
? ? ? Storyboard是重量級的,用來描述整個軟件的多個界面,并且能展示多個界面之間的跳轉關系,俗稱"故事板".
? ?3.XIB使用的分類:
? ? ? ? 3.1. xib中的內容是固定不變的,直接提供一個函數返回:
? ? ? ? + (instancetype)appView
? ? ? ? {
? ? ? ? ? ? ? ? return [NSArray arrayWithString:[NSBundle mainBundle] pathForResource:@"JHAppView"]] lastObject];
? ? ? ? }
?
? ? ? ? 3.2. 如果xib中的內容是要動態改變,則需要調用者傳遞當前模型,并重寫set方法
? ? ? ? + (instancetype)appViewWithApp:(MJApp *)app
? ? ? ? {
? ? ? ? ? ? NSBundle *bundle = [NSBundle mainBundle];
? ? ? ? ? ? // 讀取xib文件(會創建xib中的描述的所有對象,并且按順序放到數組中返回)
? ? ? ? ? ? NSArray *objs = [bundle loadNibNamed:@"JHAppView" owner:nil options:nil];
? ? ? ? ? ? JHAppView *appView = [objs lastObject];
? ? ? ? ? ? appView.app = app;
? ? ? ? ? ? return appView;
? ? ? ? }
?? ? ? ?
? ? ? ? - (void)setApp:(MJApp *)app
? ? ? ? {? ? ? ? ? ?
? ? ? ? ? ?_app = app;
? ? ? ? ??// 1.設置圖標
? ? ? ? ? ? self.iconView.image = [UIImage imageNamed:app.icon];
? ? ? ? ?// 2.設置名稱
? ? ? ? ? ? self.nameLabel.text = app.name;
? ? ? ? }
?? ? ? ?
?? ? ? ?
?
轉載于:https://www.cnblogs.com/e8net/p/3668297.html
總結
以上是生活随笔為你收集整理的xib和storyboard小谈,的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Implementation:Bellm
- 下一篇: 巧克力酱可以做什么美食(巧克力酱可以做什