久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 pagingEnabled 的 UIScrollView 中頁面之間的照片應(yīng)

Photos app-like gap between pages in UIScrollView with pagingEnabled(使用 pagingEnabled 的 UIScrollView 中頁面之間的照片應(yīng)用程序式間隙)
本文介紹了使用 pagingEnabled 的 UIScrollView 中頁面之間的照片應(yīng)用程序式間隙的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

分頁模式下的 UIScrollView 假定頁面彼此相鄰,沒有間隙.但是,如果您在照片"應(yīng)用程序中打開一張照片并在照片中滑動(dòng),您會(huì)發(fā)現(xiàn)它在頁面之間存在一些間隙.我也想要這些差距.

UIScrollView in paging mode assumes the pages are located right next to each other, with no gap. However if you open a photo in the Photos app and swipe through photos, you can see that it has some gap between pages. I want these gaps too.

我正在尋找現(xiàn)有的解決方案(如果有的話),或者除了我在下面解釋的那個(gè)之外,還有一些關(guān)于實(shí)現(xiàn)頁面間隙的更奇怪的想法.或者也許我錯(cuò)過了一些明顯的簡單方法?

I'm looking for existing solutions if any, or for some more bizarre ideas about implementing the page gaps besides the one I have explained below. Or maybe there's some obvious easy way I am missing?

明確一點(diǎn):我希望間隙僅在滾動(dòng)時(shí)可見,因此我不能簡單地插入頁面內(nèi)容.

To be clear: I want the gap to only be visible while scrolling, so I cannot simply inset the page content.

我的計(jì)劃是嘗試從 scrollViewDidScroll 回調(diào)內(nèi)部移動(dòng)頁面內(nèi)容,以便(假設(shè)您向右滾動(dòng))最初目標(biāo)頁面稍微偏移到其頁面邊界的右側(cè),當(dāng)您到達(dá)目標(biāo)頁面時(shí),它又回到了正確的位置,并且源頁面稍微偏離了其邊界的左側(cè).(或者也許不是連續(xù)移動(dòng)?xùn)|西,我會(huì)更好地移動(dòng)偏移量,比如說,正好在頁面之間的中間.)

My plan is to try moving the page content from inside scrollViewDidScroll callback, so that (assuming you're scrolling to the right) initially the target page is slightly offset to the right of its page boundaries, and by the time you arrive at the target page it's back at its proper location, and the source page is slightly offset to the left of its boundaries. (Or maybe instead of moving things continuously, I'll be better off shifting the offsets, say, exactly halfway between pages.)

我是ScrollingMadness article+example的作者把一些人介紹到這里.我已經(jīng)實(shí)現(xiàn)了程序縮放,并讓照片內(nèi)縮放+滾動(dòng)與照片間分頁一起工作.所以我知道如何使用 UIScrollView,并且正在尋找高級的東西.

I'm the author of the ScrollingMadness article+example that I've been referring some people to here. I've implemented progammatic zooming, and got in-photo zooming+scrolling working together with inter-photo paging. So I know how to play with UIScrollView, and am looking for the advanced stuff.

請不要將我指向 TTScrollView.我自己已經(jīng)向很多人指出了它,但我認(rèn)為它與原生 UIScrollView 行為相去甚遠(yuǎn),并且不想在我的項(xiàng)目中使用它.

Please don't point me at TTScrollView. I've already pointed many people to it myself, but I consider it's feel too far from the native UIScrollView behaviour, and do not want to use it in my projects.

推薦答案

請注意,這個(gè)答案已經(jīng)很老了.基本概念仍然有效,但你不應(yīng)該在 iOS7 和 8 中硬編碼視圖大小.即使你忽略這個(gè)建議,你不應(yīng)該使用 480 或 330.

Note that this answer is quite old. The basic concept still works but you should not be hard coding view sizes in iOS7 and 8. Even if you ignore that advice, you should not use 480 or 330.

您是否嘗試過使 UIScrollView 的框架略大于屏幕(假設(shè)您想全屏顯示圖像,然后將您的子視圖排列在比屏幕略大的位置上)屏幕邊界.

Have you tried making the frame of the UIScrollView slightly larger than the screen (assuming that you want to display your images fullscreen and then arranging your subviews on the same slightly-larger-than-the-screen boundaries.

#define kViewFrameWidth 330; // i.e. more than 320

CGRect scrollFrame;
scrollFrame.origin.x = 0;
scrollFrame.origin.y = 0; 
scrollFrame.size.width = kViewFrameWidth;
scrollFrame.size.height = 480;

UIScrollView* myScrollView = [[UIScrollView alloc] initWithFrame:scrollFrame];
myScrollView.bounces = YES;
myScrollView.pagingEnabled = YES;
myScrollView.backgroundColor = [UIColor redColor];

UIImage* leftImage = [UIImage imageNamed:@"ScrollTestImageL.png"];
UIImageView* leftView = [[UIImageView alloc] initWithImage:leftImage];
leftView.backgroundColor = [UIColor whiteColor];
leftView.frame = CGRectMake(0,0,320,480);

UIImage* rightImage = [UIImage imageNamed:@"ScrollTestImageR.png"];
UIImageView* rightView = [[UIImageView alloc] initWithImage:rightImage];
rightView.backgroundColor = [UIColor blackColor];
rightView.frame = CGRectMake(kViewFrameWidth * 2,0,320,480);

UIImage* centerImage = [UIImage imageNamed:@"ScrollTestImageC.png"];
UIImageView* centerView = [[UIImageView alloc] initWithImage:centerImage];
centerView.backgroundColor = [UIColor grayColor];
centerView.frame = CGRectMake(kViewFrameWidth,0,320,480);

[myScrollView addSubview:leftView];
[myScrollView addSubview:rightView];
[myScrollView addSubview:centerView];

[myScrollView setContentSize:CGSizeMake(kViewFrameWidth * 3, 480)];
[myScrollView setContentOffset:CGPointMake(kViewFrameWidth, 0)];

[leftView release];
[rightView release];
[centerView release];

抱歉,如果無法編譯,我在橫向應(yīng)用程序中對其進(jìn)行了測試,然后將其手動(dòng)編輯回縱向.我相信你明白了.它依賴于全屏視圖的超級視圖剪輯.

Apologies if this doesn't compile, I tested it in a landscape app and hand edited it back to portrait. I'm sure you get the idea though. It relies on the superview clipping which for a full screen view will always be the case.

這篇關(guān)于使用 pagingEnabled 的 UIScrollView 中頁面之間的照片應(yīng)用程序式間隙的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How to subclass UIScrollView and make the delegate property private(如何繼承 UIScrollView 并使委托屬性私有)
Swift - how to get last taken 3 photos from photo library?(Swift - 如何從照片庫中獲取最后拍攝的 3 張照片?)
Setting contentOffset programmatically triggers scrollViewDidScroll(以編程方式設(shè)置 contentOffset 觸發(fā) scrollViewDidScroll)
why UIScrollView is leaving space from top in ios 6 and ios 7(為什么 UIScrollView 在 ios 6 和 ios 7 中從頂部留下空間)
UIScrollView pauses NSTimer while scrolling(UIScrollView 在滾動(dòng)時(shí)暫停 NSTimer)
Limiting the scrollable area in UIScrollView(限制 UIScrollView 中的可滾動(dòng)區(qū)域)
主站蜘蛛池模板: 欧美激情久久久 | www.五月天婷婷.com | 日韩一区二区三区在线视频 | 欧美一区二区三区在线视频 | 男人天堂av网站 | 久久久久国产精品 | 中文无码日韩欧 | 夜夜爽99久久国产综合精品女不卡 | 亚洲第一成人影院 | 久久久久亚洲精品 | 国产伦精品一区二区三区精品视频 | 亚洲欧美中文日韩在线v日本 | 美女拍拍拍网站 | 日一区二区 | 亚洲欧美精品在线观看 | 超碰在线97国产 | 成年人免费在线视频 | 在线观看国产精品一区二区 | 久久久精彩视频 | 欧美久久久久久 | 这里只有精品999 | 精品视频一区二区三区在线观看 | 亚洲精品亚洲人成人网 | 国产在线永久免费 | 国产精品久久久久一区二区三区 | 国产精品一区二区免费 | 精品国产乱码久久久久久闺蜜 | 99免费精品 | 成人在线视频免费观看 | 国产高清在线精品一区二区三区 | 一区免费 | 国产精品无 | www.国产精 | 午夜精品在线 | 超碰人人做 | 麻豆亚洲 | 国内久久精品 | 亚洲欧美激情网 | 91精品一区二区三区久久久久久 | 中文字幕欧美日韩 | 又爽又黄axxx片免费观看 |