سؤال

أنا غير قادر على تحقيق أي رسوم متحركة مع الكود التالي:

if (self.segmentControl.selectedSegmentIndex == 0) {
    [UIView transitionFromView:tableView
                        toView:mapView
                      duration:1.0
                       options:UIViewAnimationTransitionFlipFromLeft
                    completion:nil
         ];
    }
if (self.segmentControl.selectedSegmentIndex == 1) {
    [UIView transitionFromView:mapView
                        toView:tableView
                      duration:1.0
                       options:UIViewAnimationTransitionFlipFromRight
                    completion:nil
         ];
}

وجهات النظر هي في الواقع تبديل ، ولكن فقط دون أي رسوم متحركة. إنه غريب جدا. لقد حاولت أيضا المبادلة mapView و tableView مع self.view.subviews مثل ذلك (objectAtIndex:0 هو toolBar):

if (self.segmentControl.selectedSegmentIndex == 0) {
    [UIView transitionFromView:[self.view.subviews objectAtIndex:1]
                        toView:[self.view.subviews objectAtIndex:2]
                      duration:1.0
                       options:UIViewAnimationTransitionFlipFromLeft
                    completion:nil
         ];
    }
if (self.segmentControl.selectedSegmentIndex == 1) {
    [UIView transitionFromView:[self.view.subviews objectAtIndex:2]
                        toView:[self.view.subviews objectAtIndex:1]
                      duration:1.0
                       options:UIViewAnimationTransitionFlipFromRight
                    completion:nil
         ];
}
هل كانت مفيدة؟

المحلول

أنت تستخدم الخيارات الخاطئة. مع هذه الطريقة ، يجب استخدامك الثوابت UIViewAnimationخيارTransitionFlipFromLeft و …Right في حين أن.

الثوابت القديمة UIViewAnimationTransitionFlipFromLeft و …Right يجب استخدامها فقط للطريقة غير المستندة +setAnimationTransition:…. هذه الثوابت لها قيم 1 و 2 على التوالي ، في حين أن تلك التي ذكرتها أعلاه لها قيم 1 << 20 و 2 << 20 ، والتي تختلف تمامًا.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top