7

एनिमेट नहीं है मुझे लगता है कि अपने को देखने के एक दिए गए क्षेत्र में 2 उप दृश्य नियंत्रकों के विचारों को प्रदर्शित करता है एक दृश्य नियंत्रक है। 2 उप दृश्य नियंत्रक फ्लॉपवीसी और एफआईपीवीसी हैं।transitionFromView: toView: अवधि: विकल्प: पूरा होने: संक्रमण

मैं दूसरे के लिए एक उप देखने से संक्रमण चेतन करना चाहते हैं। मैं जिस कोड का उपयोग कर रहा हूं वह है:

-(IBAction)flip:(id)sender{ 

    UIViewController *newVC = nil; 

    if (self.isFlip) { 
     newVC = [[FlopVC alloc] initWithNibName:nil bundle:nil]; 
    }else{ 
     newVC = [[FipVC alloc] initWithNibName:nil bundle:nil]; 
    } 

    newVC.view.frame = CGRectMake(120, 20, 240, 260); 
    [self.view addSubview:newVC.view]; 

    [UIView transitionFromView:self.currentVC.view 
         toView:newVC.view 
         duration:0.9 
         options:UIViewAnimationTransitionFlipFromLeft 
        completion:^(BOOL finished) { 
         self.currentVC = newVC; 
         self.isFlip = ! self.isFlip; 
        }]; 



} 

उप दृश्य स्वैप किए गए हैं, लेकिन बिना किसी एनीमेशन के। मैं क्या गलत कर रहा हूं?

पुनश्च पूर्ण परियोजना here है।

उत्तर

19
UIViewAnimationTransitionFlipFromLeft != UIViewAnimationOptionTransitionFlipFromLeft
+1

मुझे भयानक लग रहा था कि यह कुछ बेवकूफ था, लेकिन मुझे नहीं पता था कि यह बुरा था। :- मैं आपको अगले @nscoder_mad – cfischer

+0

हा पर एक बियर देना चाहता हूं, हे ... यह मुश्किल था, मेरे पास हर हफ्ते अधिक बेवकूफ गलतियां होती हैं। हालांकि मैं बियर स्वीकार करूंगा :) – djromero

+2

रड्डी नरक, मैंने अभी भी वही गलती की है। धन्यवाद Google + stackoverflow! :) (और निश्चित रूप से पागल!) –

3

अगर आप नए iOS5 दृश्य कंटेनर प्रतिमान आप निम्नलिखित की तर्ज पर कुछ करने की ज़रूरत है प्रयोग कर रहे हैं:

-(IBAction)flip:(id)sender{ 

    UIViewController *newVC = nil; 

    if (self.isFlip) { 
     newVC = [[FlopVC alloc] initWithNibName:nil bundle:nil]; 
    }else{ 
     newVC = [[FipVC alloc] initWithNibName:nil bundle:nil]; 
    } 

    newVC.view.frame = CGRectMake(120, 20, 240, 260); 

    // required for the new viewController container 
    self.currentVC willMoveToParentViewController:nil]; 
    [self addChildViewController:newVC]; 
    [self transitionFromViewController:self.currentVC 
        toViewViewController:newVC.view 
           duration:0.9 
           options: UIViewAnimationOptionTransitionFlipFromLeft 
          animations:nil 
          completion:^(BOOL finished) { 
           // required for the new viewController container 
           [self.currentVC removeFromParentViewController]; 
           [newVC didMoveToParentViewController:self]; 

           self.currentVC=newVC; 
          }]; 



} 

संदर्भ अनुभाग Implementing a Container View Controller और अधिक जानकारी के लिए UIViewController कंटेनरों पर 2011 WWDC वीडियो।

+0

"एनिमेशन" पैरामीटर के बारे में, डॉक्स राज्य "यह पैरामीटर नहीं NULL होना चाहिए।" – benvolioT

+0

howdy। यह शून्य नहीं है लेकिन शून्य है और इसे सीधे एप्पल नमूना कोड से लिया जाता है। डॉक्स प्रति:।।। "एक ब्लॉक परिवर्तनों वाली विचारों के लिए प्रतिबद्ध करने वस्तु यहां आप प्रोग्राम आपके विचार पदानुक्रम में से किसी भी दृश्य animatable गुणों को बदलने के इस ब्लॉक का कोई पैरामीटर लेता है और कोई वापसी महत्व है यह पैरामीटर शून्य नहीं होना चाहिए। " आप शून्य भेज सकते हैं क्योंकि आप शून्य को एक संदेश भेज सकते हैं। आप न्यूल को एक संदेश नहीं भेज सकते हैं। – timthetoolman

+0

स्पष्टीकरण के लिए धन्यवाद - मेरी जावा जड़ें वहां दिखाई दे रही थीं। :) – benvolioT

2

यहाँ काम कर कोड (सरासर संयोग से) आप वास्तव में क्या वर्णन कर रहे हैं करता है। मेरे दो बच्चे वीसी self->swappers में संग्रहीत हैं। पूर्णांक cur ट्रैक रखता है कि वर्तमान में कौन सा दिखा रहा है। मेरे इंटरफ़ेस में स्थान जहां सबव्यू जाना है, को व्यू आउटलेट, panel द्वारा चिह्नित किया गया है।

UIViewController* fromvc = [self->swappers objectAtIndex:cur]; 
cur = (cur == 0) ? 1 : 0; 
UIViewController* tovc = [self->swappers objectAtIndex:cur]; 
tovc.view.frame = self.panel.bounds; 

// must have both as children before we can transition between them 
[self addChildViewController:tovc]; // "will" called for us 
// note: when we call remove, we must call "will" (with nil) beforehand 
[fromvc willMoveToParentViewController:nil]; 

[self transitionFromViewController:fromvc 
        toViewController:tovc 
          duration:0.4 
          options:UIViewAnimationOptionTransitionFlipFromLeft 
         animations:nil 
         completion:^(BOOL done){ 
          // note: when we call add, we must call "did" afterwards 
          [tovc didMoveToParentViewController:self]; 
          [fromvc removeFromParentViewController]; // "did" called for us 
         }]; 
संबंधित मुद्दे