¥È¥Ã¥× ºÇ¿· Äɵ­

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


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];
ËÜÆü¤Î¥ê¥ó¥¯¸µ | 48 | 39 | 18 | 5 | 4 | 3 | 3 | 3 | 2 | 2 |

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

¡¦ Çطʤ¬Æ©¤±¤¿¥â¡¼¥À¥ë¥Ó¥å¡¼¤òɽ¼¨¤¹¤ë

Á´²èÌ̤òʤ¤¦¥Ó¥å¡¼¤ÏUIViewController¤ÎpresentModalViewController:animated:¤Ç´Êñ¤Ë¤Ç¤­¤Þ¤¹¤¬¡¢¤³¤ì¤À¤È¥â¡¼¥À¥ë¥Ó¥å¡¼¤ÎÇطʤϴ°Á´¤Ë±£¤ì¤Æ¤·¤Þ¤¤¤Þ¤¹¡£²èÌ̤ÎÂ礭¤µ¤¬Á´²èÌ̤Ǥʤ¤¾ì¹ç¤ÏÇطʤò¸«¤¨¤ë¤è¤¦¤Ë¤·¤¿Êý¤¬¼«Á³¤Ç¤¹¤¬¡¢°Ê²¼¤Î¤è¤¦¤Ë¤·¤Æ²èÌ̤ΰìÈÖÁ°¤Ëɽ¼¨¤¹¤ë¤è¤¦¤Ë¤¹¤ì¤Ð¥â¡¼¥À¥ë¤Î¤è¤¦¤Ê¸ú²Ì¤ò¼Â¸½¤Ç¤­¤ë¤è¤¦¤Ç¤¹¡£
  1. InterfaceBuilder¤Çɽ¼¨¤·¤¿¤¤¥Ó¥å¡¼¤òºîÀ®¡£background¤ÏclearColor¤ËÀßÄꤹ¤ë¡£
  2. °Ê²¼¤òViewController¤Î¼ÂÁõ¤ËÄɲá£(TestAppDelegate¤ò¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¼ÂºÝ¤Î¥Ç¥ê¥²¡¼¥È̾¤ËÃÖ¤­´¹¤¨¤ë¡Ë
    // Use this to show the modal view (pops-up from the bottom)
    - (void) showModal:(UIView*) modalView {
    	UIWindow* mainWindow = (((TestAppDelegate*) [UIApplication sharedApplication].delegate).window);
    	CGPoint middleCenter = modalView.center;
    	CGSize offSize = [UIScreen mainScreen].bounds.size;
    	CGPoint offScreenCenter = CGPointMake(offSize.width / 2.0, offSize.height * 1.5);
    	modalView.center = offScreenCenter; // we start off-screen
    	[mainWindow addSubview:modalView];    // Show it with a transition effect
    	[UIView beginAnimations:nil context:nil];   
    	[UIView setAnimationDuration:0.7];	// animation duration in seconds
    	modalView.center = middleCenter;
    	[UIView commitAnimations];
    }
    - (void) hideModal:(UIView*) modalView {
    	CGSize offSize = [UIScreen mainScreen].bounds.size;
    	CGPoint offScreenCenter = CGPointMake(offSize.width / 2.0, offSize.height * 1.5);
        [UIView beginAnimations:nil context:modalView];
    	[UIView setAnimationDuration:0.7];
    	[UIView setAnimationDelegate:self];
    	[UIView setAnimationDidStopSelector:@selector(hideModalEnded:finished:context:)];
    	modalView.center = offScreenCenter;
    	[UIView commitAnimations];
    }
    - (void) hideModalEnded:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
    	UIView* modalView = (UIView *)context;
    	[modalView removeFromSuperview]; 
    }
    
  3. ¾åµ­¤ò¸Æ¤Ó½Ð¤¹¡£¡ÊTestViewController¤ò¼ÂºÝ¤Î̾Á°¤ËÃÖ¤­´¹¤¨¤ë¡Ë
    	// ¥Ó¥å¡¼¤ò¥â¡¼¥À¥ëɽ¼¨¤¹¤ë
    	testViewController = [[TestViewController alloc] initWithNibName:@"TestViewController" bundle:nil];
    	testViewController.delegate = self;
    	[self showModal:testViewController.view];
    
»²¹Í¡§http://ramin.firoozye.com/2009/09/29/semi-modal-transparent-dialogs-on-the-iphone/
ËÜÆü¤Î¥ê¥ó¥¯¸µ | 156 | 52 | 17 | 14 | 12 | 9 | 7 | 7 | 6 | 6 |