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

scrollToTop 在 iPhone 上不工作,但在 iPad 上工作

scrollToTop is not working on iPhone but it is working on iPad(scrollToTop 在 iPhone 上不工作,但在 iPad 上工作)
本文介紹了scrollToTop 在 iPhone 上不工作,但在 iPad 上工作的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有兩個視圖控制器.一個用于頁面控制的滾動視圖和一個用于詳細信息的滾動視圖(垂直滾動).

I have two view controller. One scrollview for page control and one for detail (scroll vertical).

當我在 iPhone 上單擊狀態欄時,scrollToTop 不起作用,而在 iPad 中,scrollToTop 正在工作.

When i click status bar on iPhone the scrollToTop not working, and in iPad the scrollToTop is working.

我確定 scrollView.scrollToTop 是 YES.因為我已經打印出來了.

I am sure that the scrollView.scrollToTop is YES. because i already print it.

誰知道是什么原因導致 iPhone 的 scrollToTop 不工作?

Anyone know what cause the iPhone scrollToTop not working?

謝謝

我嘗試調用 scrollView 委托.在 iPad 中,這個委托被稱為.- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView

I try by calling the scrollView delegate. in iPad this delegate its called. - (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView

在 iPhone 中它不被調用.我已經同時使用了contentScrollView.delegate = self;但是iphone不工作:(

in iPhone it is not called. I already use both contentScrollView.delegate = self; But the iphone not working :(

嘗試子類化 UIWindow(不工作)

Try subclassing UIWindow (not working)

窗口.h

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface Window : UIWindow
@end

窗口.m

 #import "Window.h"

 @implementation Window

 - (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
if ([event type] == UIEventTypeTouches && point.y < 250) {
    //Send Your Notification Here
    NSLog(@"KAROOO");
}
NSLog(@"HELLOWW");
return [super hitTest:point withEvent:event];
}
@end

AppDelegate.h

AppDelegate.h

@property (nonatomic, strong) IBOutlet Window *window;

AppDelegate.m

AppDelegate.m

@synthesize window = _window;

推薦答案

據我了解,您的屏幕上同時有 2 個 UIScrollView.

From what I understand you have 2 UIScrollViews simultaneously on screen.

據我所見&有經驗的,在 iOS 4 上并排有 2 個 UIScrollView 會產生未定義的行為.其中一個滾動視圖可能會滾動,有時可能會滾動,有時兩者都不會.

From what I have seen & experienced, On iOS 4 having 2 UIScrollViews side by side gives undefined behaviour. One of the scrollview may scroll, sometimes other, sometimes neither.

在 iOS 5 上,如果您并排有 2 個 UIScrollView,然后點擊狀態欄滾動到頂部"UIScrollView 右側在您的點擊下"

On iOS 5 if you have 2 UIScrollViews side by side then tapping on status bar "scrolls to top" the UIScrollView right "under your tap"

我不知道這是如何工作的,但這是我的觀察.iOS 5 很智能??!

I don't know how this works, but this has been my observation. iOS 5 is smart !!

如果您的 UIScrollViews 高于其他,則可能行為未定義.我沒查過.

If your UIScrollViews are one above other then probably the behaviour is undefined. I haven't checked.

希望這會有所幫助.

如果你想讓它正常工作,那么這里有一個可能的解決方案.

If you want to get it working anyways then here is a possible solution.

子類 或在 UIWindow 上添加一個類別并添加一個手勢識別器/或實現僅檢測 Y <的點擊的 hitTest20 以此類推,然后讓它發送通知并在您的 viewController 中收聽,并以編程方式將 UIScrollView 滾動到頂部.

Subclass or Add a category on UIWindow and add a gesture recognizer / or implement hitTest that detects tap only for Y < 20 and so on and then have it send a notification and listen to this in your viewController and programmatically scroll the UIScrollView to top.

編輯

在 UIWindow 子類 (iPad) 中實現它

Implement this in the UIWindow subclass (iPad)

- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
    if ([event type] == UIEventTypeTouches && point.y < 20 && [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait) {
        NSLog(@"Portrait");
    } else if ([event type] == UIEventTypeTouches && point.y > 1004 && [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown) {
        NSLog(@"PortraitUpsideDown");
    } else if ([event type] == UIEventTypeTouches && point.x < 20 && [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft) {
        NSLog(@"LandscapeLeft");
    } else if ([event type] == UIEventTypeTouches && point.x > 748 && [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight) {
        NSLog(@"LandscapeRight");
    }
    return [super hitTest:point withEvent:event];
}

這篇關于scrollToTop 在 iPhone 上不工作,但在 iPad 上工作的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

how to set scrollview content size in swift 3.0(如何在 swift 3.0 中設置滾動視圖內容大小)
Stop a UITableView from automatically scrolling(阻止 UITableView 自動滾動)
iOS UIScrollView Lazy Loading(iOS UIScrollView 延遲加載)
using iOS 6.0 SDK and building for iOS 5 Target causes UIScrollView setMinimumZoomScale to fail when running on iOS 5 simulator(在 iOS 5 模擬器上運行時,使用 iOS 6.0 SDK 并為 iOS 5 Target 構建會導致 UIScrollView setMinimumZ
Create partial-screen UIPageViewController programmatically(以編程方式創建部分屏幕 UIPageViewController)
how to make an ImageView zoomable with or without ScrollView.?(如何使用或不使用 ScrollView 使 ImageView 可縮放?)
主站蜘蛛池模板: 中国免费黄色片 | 欧美群妇大交群中文字幕 | h视频在线看 | 日韩高清成人 | 五月婷婷激情 | 81精品国产乱码久久久久久 | 亚洲视频三区 | 日韩欧美大片在线观看 | 日韩不卡三区 | 手机av在线| 欧美成年网站 | 资源首页二三区 | 女同久久另类99精品国产 | 日韩在线观看视频一区 | 91久久久久久久久 | 99久久免费精品国产男女高不卡 | 午夜精品一区 | 国产一区 | 欧美日韩精品一区二区三区视频 | 欧美一级黄色片在线观看 | 亚洲91精品 | 日韩视频在线播放 | 一区二区亚洲 | 国产精品久久久亚洲 | 国产农村妇女毛片精品久久麻豆 | 精品久久久久久亚洲国产800 | 中文字幕一区二区三区四区五区 | 秋霞av国产精品一区 | 久久综合伊人 | 一级毛片视频 | 欧美久久久久久 | 欧美日韩精品一区二区三区四区 | 国产精品久久久久影院色老大 | 欧美日韩中文字幕在线 | 国产黄色在线观看 | 久久精品国产一区二区电影 | 国产综合精品一区二区三区 | 黄色片在线网站 | 在线一区观看 | 久久精品在线 | 日韩中文字幕在线免费 |