我通过实现UIViewControllerTransitioningDelegate协议中的方法为模态视图控制器创建了自定义过渡动画.
在iOS 8和9中,方法被正常调用并且过渡有效.但是,在iOS 7中,animationControllerForPresentedController:presentingController:sourceController:永远不会调用该方法.该animationControllerForDismissedController:方法仍然被正常调用.
#import "MyModalTransitioningDelegate.h"
#import "MyModalFadeTransition.h"
@implementation MyModalTransitioningDelegate
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented
presentingController:(UIViewController *)presenting
sourceController:(UIViewController *)source
{
return [[MyModalFadeTransition alloc] init];
}
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed
{
return [[MyModalFadeTransition alloc] init];
}
@end
Run Code Online (Sandbox Code Playgroud)
在模态视图控制器(即"呈现的控制器")中,我在其-viewDidLoad方法中有以下内容:
self.modalTransitionDelegate = [[OTModalTransitioningDelegate alloc] init]; // This is a custom strong private property due to `tranisitioningDelegate` being a weak property.
self.transitioningDelegate = self.modalTransitionDelegate;
self.modalPresentationStyle = UIModalPresentationCustom;
Run Code Online (Sandbox Code Playgroud)
modalPresentationStyle在任何版本的iOS中设置似乎没有任何区别.没有被调用的方法确实说它在iOS 7中可用,所以我不确定它为什么没有被调用.
模式视图控制器在呈现视图控制器中显示以下代码:
[self presentViewController:self.modalViewController
animated:YES
completion:nil];
Run Code Online (Sandbox Code Playgroud) - (BOOL)mySetting
{
return [myObject returnYes];
}
Run Code Online (Sandbox Code Playgroud)
对于上面这样的方法,是否可以使用调试器命令添加断点,以便该-mySetting方法NO在启用断点时自动返回不同的值(例如)?
我正在寻找一个选项,其中调试器不必中断应用程序的执行,(又名“评估操作后自动继续”已打开)。
我有三个指针*player1,*player2和*currentPlayer.
指针*currentPlayer始终指向*player1或*player2.要在两者之间切换,我一直在做以下事情:
if (currentPlayer == player1) {
currentPlayer = player2;
}
else {
currentPlayer = player1;
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,是否有更简单,更优雅的方式来交换这两个指针?