交叉溶解过渡干扰 UIPageController 页面上的页面卷曲
Cross-dissolve transitions interfering with page curls on UIPageController pages
我在我的 UIPageController subclass 页面上的图像之间交叉溶解。在应用过渡时可以翻页。有时,正在翻页的页面会在翻页中变为透明,直到转换完成。
在下面的代码中,Page class 是 UIViewController 的子class,它的视图有一个 UIImageView 子视图。 PageController 是我的 UIPageViewController subclass。
@implementation PageController : UIPageViewController
- (void)crossfadeToImage:(UIImage *)image
{
for (int i = 0; i < self.pages.count; i++) {
Page *page = self.pages[i]; // Pages fed to page controller in delegate
[UIView transitionWithView:page.view duration:duration options:UIViewAnimationOptionTransitionCrossDissolve | UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionCurveEaseInOut animations:^{
page.image = image;
} completion:nil];
}
}
页面代码如下:
// HEADER
@interface Page : UIViewController
@property (strong, nonatomic) UIImage *image;
- (instancetype)initWithPageFrameSize:(CGSize)size image:(UIImage *)image;
@end
// IMPLEMENTATION
@implementation Page
- (void)loadView
{
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, _pageFrameSize.width, _pageFrameSize.height)];
self.view = view;
}
- (UIImage *)image
{
return _imageView.image;
}
- (void)setImage:(UIImage *)image
{
if (!_imageView) {
_imageView = [[UIImageView alloc] initWithImage:image];
_imageView.frame = self.view.bounds;
[self.view addSubview:_imageView];
} else {
_imageView.image = image;
}
}
@end
我猜交叉淡入淡出和卷页动画以某种奇怪的方式堆叠。关于如何防止这种 "disappearing page" 副作用的任何想法?
原来将动画应用到 imageView 直接解决了这个问题。类似于:
- (void)crossfadeToImage:(UIImage *)image
{
for (int i = 0; i < self.pages.count; i++) {
Page *page = self.pages[i]; // Pages fed to page controller in delegate
[UIView transitionWithView:page.**imageView** duration:duration options:UIViewAnimationOptionTransitionCrossDissolve | UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionCurveEaseInOut animations:^{
page.**imageView**.image = image;
} completion:nil];
}
}
不过,欢迎任何关于为什么它不能以其他方式工作的见解。
我在我的 UIPageController subclass 页面上的图像之间交叉溶解。在应用过渡时可以翻页。有时,正在翻页的页面会在翻页中变为透明,直到转换完成。
在下面的代码中,Page class 是 UIViewController 的子class,它的视图有一个 UIImageView 子视图。 PageController 是我的 UIPageViewController subclass。
@implementation PageController : UIPageViewController
- (void)crossfadeToImage:(UIImage *)image
{
for (int i = 0; i < self.pages.count; i++) {
Page *page = self.pages[i]; // Pages fed to page controller in delegate
[UIView transitionWithView:page.view duration:duration options:UIViewAnimationOptionTransitionCrossDissolve | UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionCurveEaseInOut animations:^{
page.image = image;
} completion:nil];
}
}
页面代码如下:
// HEADER
@interface Page : UIViewController
@property (strong, nonatomic) UIImage *image;
- (instancetype)initWithPageFrameSize:(CGSize)size image:(UIImage *)image;
@end
// IMPLEMENTATION
@implementation Page
- (void)loadView
{
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, _pageFrameSize.width, _pageFrameSize.height)];
self.view = view;
}
- (UIImage *)image
{
return _imageView.image;
}
- (void)setImage:(UIImage *)image
{
if (!_imageView) {
_imageView = [[UIImageView alloc] initWithImage:image];
_imageView.frame = self.view.bounds;
[self.view addSubview:_imageView];
} else {
_imageView.image = image;
}
}
@end
我猜交叉淡入淡出和卷页动画以某种奇怪的方式堆叠。关于如何防止这种 "disappearing page" 副作用的任何想法?
原来将动画应用到 imageView 直接解决了这个问题。类似于:
- (void)crossfadeToImage:(UIImage *)image
{
for (int i = 0; i < self.pages.count; i++) {
Page *page = self.pages[i]; // Pages fed to page controller in delegate
[UIView transitionWithView:page.**imageView** duration:duration options:UIViewAnimationOptionTransitionCrossDissolve | UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionCurveEaseInOut animations:^{
page.**imageView**.image = image;
} completion:nil];
}
}
不过,欢迎任何关于为什么它不能以其他方式工作的见解。