我有一个CGContextDrawPDFPage在QuartzDemo示例应用程序中显示的pdf页面。
我想保持这个页面显示,并有一个图像幻灯片从上面的这一页,就像它可以看到在iBooks应用程序。
这是一本书,滑动图像是一个书签,当你即将关闭这本书时,它会滑入其中。
我用DyingCactus添加了以下代码(提示:我是obj和iphone的新手):
在QuartzViewController.m中,动画开始显示,但是视图在动画完成之前就会滑动,事实上,我认为动画是在视图滑动时继续进行的。
-(void)viewWillDisappear:(BOOL)animated
{
[self.quartzView setFrame:CGRectMake(150, -200, 100, 200)];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[self.quartzView setFrame:CGRectMake(150, 0, 100, 200)];
[UIView commitAnimations];
}如何在视图消失之前保持视图可见并完成动画?
发布于 2010-05-30 13:16:03
我想你是在修改苹果的QuartzDemo示例应用程序。
我现在能想到的最好的方法是,当显示的视图是PDF视图时,用您自己的按钮替换导航控制器上的后退按钮。
然后,您的自定义回退按钮可以根据需要管理动画和查看弹出序列。
唯一恼怒的是,后退按钮不再有左箭头形状。
以下是QuartzViewController.m中所需的更改:
#import "QuartzImages.h" //<-- add this import
...
-(void)viewDidLoad
{
// Add the QuartzView
[scrollView addSubview:self.quartzView];
//add custom back button if this is the PDF view...
if ([self.quartzView isKindOfClass:[QuartzPDFView class]])
{
self.navigationItem.leftBarButtonItem =
[[UIBarButtonItem alloc] initWithTitle:@"QuartzDemo"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(myBackButtonHandler:)];
}
}
- (void)myBackButtonHandler:(id)sender
{
[self.quartzView setFrame:CGRectMake(150, -200, 100, 200)];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[UIView setAnimationDuration:1.0];
[self.quartzView setFrame:CGRectMake(150, 0, 100, 200)];
[UIView commitAnimations];
}
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
[self.navigationController popViewControllerAnimated:YES];
}https://stackoverflow.com/questions/2938312
复制相似问题