2017年1月7日 星期六
2016年3月23日 星期三
在 didFinishLaunchingWithOptions 時不使用 storyboard 直接載入 nib 檔
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] ;
// Override point for customization after application launch.
MyViewController *test = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:test];
self.window.rootViewController = nav;
[self.window makeKeyAndVisible];
return YES;
}
2016年3月7日 星期一
Creating a TableView in XIB
Creating a TableView in XIB
Ref: http://bcdilumonline.blogspot.tw/2014/08/creating-tableview-in-xib.html
Ref: http://bcdilumonline.blogspot.tw/2014/08/creating-tableview-in-xib.html
2016年2月11日 星期四
什麼是 Outlets 和 Referencing Outlets
在 IB 裡的 Show the Connections inspector 頁面,可以看到 Outlets 和 Referencing Outlets,每次基本一定要設定的就是 UIViewController 與 UIView 與之間的連接。
對於 UIViewController 來說,Outlets 可以說是底下的 view 和為 IBOutlet 的那些 properties,所以從圖1 中可以看到 UIViewController 有兩個 Outlets 分別為 view 和 simpleTableView 對應著這個 nib 檔中別名為 View 和 Simple Table View 的元件。而 Referencing Outlets 則為自己被外部的哪些 Objects 所引用,以圖1來說,因為這個 UIViewController 放了一個 UITableView,而 UITableView 擁有 dataSource 和 delegate 的 properties,需要讓他們引用 UIViewController,這也是為什麼需要讓 UIViewController 實作 UITableViewDelegate 和 UITableViewDataSource 。
![]() |
| 圖1. File's Owner Connections |
另外從 UITableView 的角度來看,他的 Outlets 則是 dataSource 和 delegate,而 Referencing Outlets 則是 simpleTableView。
![]() |
| 圖2. UITableView Connections |
2014年11月12日 星期三
What is the use of "#pragma mark" in codes?
訂閱:
文章 (Atom)


