¥È¥Ã¥× «Á°¤ÎÆüµ­(2010-09-30) ºÇ¿· ¼¡¤ÎÆüµ­(2010-10-05)» ÊÔ½¸

¥µ¥¤¥é¥¹¤ÎËÜê


2010-10-01 iPhone¥×¥í¥°¥é¥ß¥ó¥°Tips

¡¦ [iOS][Xcode]¥¿¥Ö¤ÎÃæ¤Ë¥Ê¥Ó¥²¡¼¥·¥ç¥ó¥Ð¡¼¤òɽ¼¨¤¹¤ëÊýË¡

¥¿¥Ö¥Ð¡¼¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤¢¤ë¥¿¥Ö¤Ë¥Æ¡¼¥Ö¥ë¥Ó¥å¡¼¤òɽ¼¨¤·ÊÔ½¸¥Ü¥¿¥ó¤ò²¡¤¹¤È¥ê¥¹¥È¤ÎÊÔ½¸¤ò¹Ô¤¨¤ë¤è¤¦¤Ë¤·¤¿¤¤¤è¤¦¤Ê¤È¤­¤Ë¡¢¥¿¥Ö¤Ë¥Ê¥Ó¥²¡¼¥·¥ç¥ó¥Ð¡¼¤òɽ¼¨¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¤¬¡¢°Ê²¼¤Î¤è¤¦¤Ë¹Ô¤¨¤Þ¤¹¡£
(AppDelegete¥¯¥é¥¹¤Î¥Ø¥Ã¥À¤Ë¤Æ°Ê²¼¤òÄêµÁ¡Ë
UITabBarController *tabBarController;
UINavigationController *navigationController;
UITableViewController *tableViewController;
(AppDelegate¥¯¥é¥¹¤ÎdidFinishLaunching¤Ë¤Æ¡£TableViewController¤Î¼ÂÁõ¤Ï¾Êά¡£)
//¥Ê¥Ó¥²¡¼¥·¥ç¥ó¥³¥ó¥È¥í¡¼¥é¤ÎÀ¸À®
navigationController = [[UINavigationController alloc] initWithRootViewController:tableViewController];
navigationController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"List" image:nil tag:1];
//¥¿¥Ö¥Ð¡¼¥³¥ó¥È¥í¡¼¥é¤ÎÀ¸À®
NSMutableArray *viewControllers = [[NSMutableArray alloc] init];
[viewControllers addObject:navigationController];
tabBarController = [[UITabBarController alloc] init];
tabBarController.viewControllers = viewControllers;
// Add the tab bar controller's current view as a subview of the window
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
¥Ý¥¤¥ó¥È¤Ï¡¢
  • navigationController¤ÎRootViewController¤È¤·¤Æ¥Ê¥Ó¥²¡¼¥·¥ç¥ó¥Ð¡¼¤òÄɲä·¤¿¤¤ViewController(¤³¤³¤Ç¤ÏtableViewController)¤òÀßÄꤷ
  • tabBarController¤ÎviewControllers¤ËÄɲ乤ë¤Î¤Ï¤³¤ÎnavigationController¤Ç¤¢¤ë
¤È¤¤¤¦¤³¤È¤Ç¤¹¡£

¡¦ [iOS][Xcode]InterfaceBuilder¤Î¥Æ¥ó¥×¥ì¡¼¥È(.xib)¤«¤éViewController¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤òÀ¸À®¤¹¤ëÊýË¡

¤³¤¦¤¹¤ë¤È¡¢¥Ó¥å¡¼¤ÎUI¤Ë´Ø¤¹¤ë¾ðÊó¤ÏInterfaceBuilder¤ÇºîÀ®¤·¡¢¥Ó¥å¡¼¥³¥ó¥È¥í¡¼¥é¥¯¥é¥¹¤Ï¼«ºî¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
InterfaceBuilder¤ÇºîÀ®¤·¤¿MyViewController.xib¤È¤¤¤¦¥Æ¥ó¥×¥ì¡¼¥È¥Õ¥¡¥¤¥ë¤¬¥×¥í¥¸¥§¥¯¥È¤ÎResources¥Õ¥©¥ë¥À¤ËÄɲ䵤ì¤Æ¤¤¤ë¤È¤·¤Þ¤¹¡£
MyViewController *myViewController = 
[[MainViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
ËÜÆü¤Î¥ê¥ó¥¯¸µ