csc*_*uff 6 storyboard ios ios5 segue
我正在尝试实现类似iBooks的翻转过渡作为故事板.segue应该推动.弹出destinationViewController
UINavigationControllers堆栈.
我可以在我的segues perform
方法中推送viewcontrollers,但我无法弹出.当我在创建翻转动画后立即弹出控制器时,动画不会运行,并且它的回调 - 应执行的回调[[UIApplication sharedApplication] endIgnoringInteractionEvents]
永远不会被调用,而我的应用程序结果已经死亡.
所以我尝试在animationDidStop:anim:flag
委托方法中推送/弹出,但它永远不会被调用,标志设置为true.
我假设在调用委托方法之前释放segue.我还能做什么?
请原谅我,如果我完全误解了这个问题,但似乎你只想在两个视图控制器之间来回做一个基本的水平翻转.即使你已经想到这一点,也许它会帮助其他有同样问题的人.
(1)在你的故事板(有ViewController A和B)中创建一个从A到B的模态Segue.给它一个标识符(showViewControllerB)并选择Transition:Flip Horizontal.
我们设置了协议和代表:
(2a)在ViewControllerB.h中添加@interface以上:
@class ViewControllerB;
@protocol ViewControllerBDelegate
- (void)viewControllerBDidFinish:(ViewControllerB *)controller;
@end
Run Code Online (Sandbox Code Playgroud)
(2b)将委托添加为属性:
@property (weak, nonatomic) id <ViewControllerBDelegate> delegate;
Run Code Online (Sandbox Code Playgroud)
(3a)在ViewControllerB.m中合成:
@synthesize delegate;
Run Code Online (Sandbox Code Playgroud)
(3b)并在方法中委托翻转:
- (IBAction)flipBack:(id)sender
{
[self.delegate viewControllerBDidFinish:self];
}
Run Code Online (Sandbox Code Playgroud)
(4)在ViewControllerA.h中添加#import "ViewControllerB.h"
@interface的顶部和末尾<ViewControllerBDelegate>
(5a)在ViewControllerA.m中添加符合协议的方法:
- (void)viewControllerBDidFinish:(ViewControllerB *)controller
{
[self dismissModalViewControllerAnimated:YES];
}
Run Code Online (Sandbox Code Playgroud)
(5b)然后将其设置为prepareForSegue中的委托:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"showViewControllerB"]) {
[[segue destinationViewController] setDelegate:self];
}
}
Run Code Online (Sandbox Code Playgroud)
我希望这回答了你的问题.如果我误解了,请告诉我.
归档时间: |
|
查看次数: |
4317 次 |
最近记录: |