TTPhotoViewController 在不同interfaceOrientation下的显示问题
来源:互联网 发布:最奇葩的淘宝差评有图 编辑:程序博客网 时间:2024/05/20 05:04
http://blog.csdn.net/gavinming/article/details/6756769
最近在使用Three20库进行开发,并使用了TTPhotoViewController 来显示照片,不清楚大家是否遇到过我这样的问题:直接TTPhotoViewController ,使用在竖屏的时候,图片显示是错误了,此时图片上自动放大,且经常会显示到其他页的图片;而在横屏的情况下是正确的。
参考了网上一些解决方法:将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];
- <span style="color:#ff0000;"> </span>[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 在不同interfaceOrientation下的显示问题
- 解决toolbar在不同页面下显示的menu不同的问题
- UIViewController.interfaceOrientation 在ios5版本下 横屏是初始化判断无效
- shape在不同机型的显示问题
- 解决qt在相同分辨率不同宽度的屏幕下字体显示位置不一样的问题
- 后台拼接html代码在不同浏览器下显示的问题
- PS1在不同的用户下显示不一样
- 网页在不同的分辨率下始终居中显示
- 关于AndroidStudio下package不同显示的问题
- png在ie6下的显示问题
- Textarea在IE下的显示问题
- 自定义UI在不同的LookAndFeel下的替换问题.
- 在ios 下获取 rootviewcontroller 的版本不同的问题
- 如何解决css样式表在不同浏览器中显示效果不同的问题
- 如何解决css样式表在不同浏览器中显示效果不同的问题
- 如何解决css样式表在不同浏览器中显示效果不同的问题
- input框在不同浏览器下面显示不同的结构问题
- Jsonp 方式跨域获取 json 数据原理
- TopCoder兼职赚钱入门
- 近乎完美的简单 JS 跨域解决方式 --window.name
- C++中竟然可以用 ... 这样省略形参
- 数据集
- TTPhotoViewController 在不同interfaceOrientation下的显示问题
- JSONP原理及最简单的JSONP实现
- Extjs4 API文档阅读--Ext.button.Button
- iphone javascript jscocoa
- JAVA 基于TCP协议编写的Socket聊天室程序
- eclipseuml和android development tools有冲突,怎样解决?
- 分析一下12306网站
- seo教程之网站页面价值判断的三大因素
- 我学习编程的好的学习方法!