TTPhotoViewController 在不同interfaceOrientation下的显示问题
2011-09-07 14:57
453 查看
最近在使用Three20库进行开发,并使用了TTPhotoViewController 来显示照片,不清楚大家是否遇到过我这样的问题:直接TTPhotoViewController ,使用在竖屏的时候,图片显示是错误了,此时图片上自动放大,且经常会显示到其他页的图片;而在横屏的情况下是正确的。
参考了网上一些解决方法:将TTPhotoView.m的- (void)setImage:(UIImage*)image函数中的UIViewContentModeScaleAspectFill改为UIViewContentModeScaleAspectFit,依照该方法修改后,此时发现竖屏是正确的,但是横屏确显示的是小图,无法满屏显示。
由此得出,在不同的interfaceOrientation下,需设置不同的contentmode。因此经过实验,修改代码如下:
TTPhotoViewController .m
增加函数:updatePhotoViewContentMode:(UIInterfaceOrientation)interfaceOrientation
修改代码:
参考了网上一些解决方法:将TTPhotoView.m的- (void)setImage:(UIImage*)image函数中的UIViewContentModeScaleAspectFill改为UIViewContentModeScaleAspectFit,依照该方法修改后,此时发现竖屏是正确的,但是横屏确显示的是小图,无法满屏显示。
由此得出,在不同的interfaceOrientation下,需设置不同的contentmode。因此经过实验,修改代码如下:
TTPhotoViewController .m
增加函数:updatePhotoViewContentMode:(UIInterfaceOrientation)interfaceOrientation
/////////////////////////////////////////////////////////////////////////////////////////////////// - (void)updatePhotoViewContentMode:(UIInterfaceOrientation)interfaceOrientation { TTPhotoView* centerPhotoView = self.centerPhotoView; UIViewContentMode currentContentMode; if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) { currentContentMode = UIViewContentModeScaleAspectFill; } else{ currentContentMode = UIViewContentModeScaleAspectFit; } //先设置非当前view到contentMode,防止旋转时,会看到非centerPhotoview for (TTPhotoView* photoView in _scrollView.visiblePages.objectEnumerator) { if (centerPhotoView == photoView) break; photoView.contentMode = currentContentMode; } centerPhotoView.contentMode = currentContentMode; }
修改代码:
/////////////////////////////////////////////////////////////////////////////////////////////////// - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration]; [self updateToolbarWithOrientation:toInterfaceOrientation]; [self updatePhotoViewContentMode:toInterfaceOrientation]; }
/////////////////////////////////////////////////////////////////////////////////////////////////// - (void)loadImages { TTPhotoView* centerPhotoView = self.centerPhotoView; for (TTPhotoView* photoView in _scrollView.visiblePages.objectEnumerator) { if (photoView == centerPhotoView) { [photoView loadPreview:NO]; } else { [photoView loadPreview:YES]; } //修改interfaceOrientation if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation)){ photoView.contentMode = UIViewContentModeScaleAspectFill; } else{ photoView.contentMode = UIViewContentModeScaleAspectFit; } } if (_delayLoad) { _delayLoad = NO; [self startImageLoadTimer:kPhotoLoadLongDelay]; } else { [centerPhotoView loadImage]; } }
相关文章推荐
- TTPhotoViewController 在不同interfaceOrientation下的显示问题
- (转)使用TTPhotoViewController显示本地图片
- 如何利用TTThumbsViewController实现显示不同数量的图片?
- shape在不同机型的显示问题
- 完美解决C# DataGridView控件显示不同表的问题
- CTAssetsPickerController 选中图片不显示对号的问题解决
- rose中interface的4种不同显示
- android 保存具有不同前缀的同一号码分别为A和B,用其中一个呼叫,通话记录一直显示另一个联系人名字的问题
- TTPhotoViewController 明天可以试试2
- ipad开发中UIPopoverController中显示自定义view尺寸显示问题
- [置顶] 文字内容溢出用点点点(…)省略号 在不同浏览器里的 显示位置问题
- AJ学IOS 之控制器view显示中view的父子关系及controller的父子关系_解决屏幕旋转不能传递事件问题
- IOS UINavigationController的下级页面(子页面)更改titleView不显示的问题
- PhotoView无法显示大图片问题
- java setVisible顺序不同导致窗体内容不显示问题
- 后台拼接html代码在不同浏览器下显示的问题
- 前端传递参数,在Controller显示问号乱码的问题?
- 请大侠指教uiviewcontroller中添加了scrollview来实现多屏显示的的问题
- CTAssetsPickerController 选中图片不显示对号的问题解决
- 任务栏按钮分组后显示的名字不同问题分析