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

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


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/
ËÜÆü¤Î¥ê¥ó¥¯¸µ