久久久久久久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 可縮放?)
主站蜘蛛池模板: 国产亚洲欧美另类一区二区三区 | 国产精品免费播放 | 国产一区二区不卡 | 密桃av| 久久精品一区二区视频 | 老司机午夜性大片 | 亚洲欧洲在线视频 | 久久黄色网| 国产资源在线播放 | 国产免费观看视频 | 2018中文字幕第一页 | 91欧美激情一区二区三区成人 | 在线中文字幕亚洲 | 婷婷99| 久久免费国产 | 伊人精品 | 国产精品毛片无码 | 午夜视频在线免费观看 | 色香婷婷| 国产一区精品 | 黄色一级大片在线免费看产 | 日韩成人免费在线视频 | 中文天堂在线一区 | 久久久久中文字幕 | 视频一区在线观看 | 国产专区视频 | 久久亚洲一区二区三区四区 | 欧美日韩一区二区三区四区 | 国产视频一区二区 | 国产精品自拍一区 | 四虎成人在线播放 | 久久国产日韩欧美 | 一区二区精品在线 | 国产玖玖 | 黄色福利 | 亚洲成a| 天天拍天天操 | 亚洲欧美日韩一区二区 | 亚洲精品国产一区 | 欧美区在线 | 97国产精品视频人人做人人爱 |