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

讓滾動條在 UIScrollView 上始終可見?

Make scrollbar always visible on UIScrollView?(讓滾動條在 UIScrollView 上始終可見?)
本文介紹了讓滾動條在 UIScrollView 上始終可見?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我需要在 viewDidLoad 上創建一個始終可見的滾動條,以便用戶可以了解有要滾動的內容.我做了以下事情:

[myscrollView flashScrollIndicators];

但隨后滾動條僅在 viewDidLoad 后出現一段時間,然后再次消失,僅在用戶觸摸屏幕時重新出現..

我需要讓滾動條始終可見.我該怎么做?

解決方案

Apple 間接不鼓勵在其

  • UIScrollView 指示器總是顯示?
  • 滾動指示器可見性
  • 使滾動條在 uiscrollview 中始終可見
  • I need to make a scrollbar always visible on viewDidLoad so that the user can understand that there is content to scroll. I did the following:

    [myscrollView flashScrollIndicators];
    

    But then the scrollbars only appear for some time after viewDidLoad and disappear again only to reappear when the user touches the screen..

    I need to make scrollbars always visible. How can I do it?

    解決方案

    Apple indirectly discourage constantly displaying scroll indicators in their iOS Human Interface Guidelines but guidelines are just guidelines for a reason, they don't account for every scenario and sometimes you may need to politely ignore them.

    The scroll indicators of any content views are UIImageView subviews of those content views. This means you can access the scroll indicators of a UIScrollView as you would any of its other subviews (i.e. myScrollView.subviews) and modify the scroll indicators as you would any UIImageView (e.g. scrollIndicatorImageView.backgroundColor = [UIColor redColor];).

    The most popular solution appears to be the following code:

    #define noDisableVerticalScrollTag 836913
    #define noDisableHorizontalScrollTag 836914
    
    @implementation UIImageView (ForScrollView) 
    
    - (void) setAlpha:(float)alpha {
    
        if (self.superview.tag == noDisableVerticalScrollTag) {
            if (alpha == 0 && self.autoresizingMask == UIViewAutoresizingFlexibleLeftMargin) {
                if (self.frame.size.width < 10 && self.frame.size.height > self.frame.size.width) {
                    UIScrollView *sc = (UIScrollView*)self.superview;
                    if (sc.frame.size.height < sc.contentSize.height) {
                        return;
                    }
                }
            }
        }
    
        if (self.superview.tag == noDisableHorizontalScrollTag) {
            if (alpha == 0 && self.autoresizingMask == UIViewAutoresizingFlexibleTopMargin) {
                if (self.frame.size.height < 10 && self.frame.size.height < self.frame.size.width) {
                    UIScrollView *sc = (UIScrollView*)self.superview;
                    if (sc.frame.size.width < sc.contentSize.width) {
                        return;
                    }
                }
            }
        }
    
        [super setAlpha:alpha];
    }
    
    @end
    

    Which is originally credited to this source.

    This defines a category for UIImageView that defines a custom setter for the alpha property. This works because at some point in the underlying code for the UIScrollView, it will set its scroll indicator's alpha property to 0 in order to hide it. At this point it will run through our category and, if the hosting UIScrollView has the right tag, it will ignore the value being set, leaving it displayed.

    In order to use this solution ensure your UIScrollView has the appropriate tag e.g.

    If you want to display the scroll indicator from the moment its UIScrollView is visible simply flash the scroll indicators when the view appears .e.g

    - (void)viewDidAppear:(BOOL)animate
    {
        [super viewDidAppear:animate];
        [self.scrollView flashScrollIndicators];
    }
    

    Additional SO references:

    • UIScrollView - showing the scroll bar
    • UIScrollView indicator always show?
    • Scroll Indicators Visibility
    • Make scrollbars always visible in uiscrollview

    這篇關于讓滾動條在 UIScrollView 上始終可見?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

    相關文檔推薦

    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(以編程方式設置 contentOffset 觸發 scrollViewDidScroll)
    Photos app-like gap between pages in UIScrollView with pagingEnabled(使用 pagingEnabled 的 UIScrollView 中頁面之間的照片應用程序式間隙)
    why UIScrollView is leaving space from top in ios 6 and ios 7(為什么 UIScrollView 在 ios 6 和 ios 7 中從頂部留下空間)
    UIScrollView pauses NSTimer while scrolling(UIScrollView 在滾動時暫停 NSTimer)
    主站蜘蛛池模板: 久久国产精品视频 | a在线视频 | 国产亚洲精品久久久久动 | 精品日韩一区二区 | 成人精品国产免费网站 | 精品久久国产 | aaa精品 | 黄色网页在线观看 | 91视频网址 | 国产日韩欧美一区 | 欧美精品福利 | 国产精品1区2区 | 爱爱爱av | 久在线| 国产精品久久久久一区二区三区 | 欧美成人精品 | 精品久久国产老人久久综合 | 色婷婷精品国产一区二区三区 | 亚洲精品日韩一区二区电影 | 日本人做爰大片免费观看一老师 | 亚洲欧美成人 | 亚洲视频国产 | 国产第1页 | 亚洲乱码一区二区三区在线观看 | 国产精品一区二区三区久久久 | 日韩影院在线观看 | 精品成人在线 | 色婷婷av一区二区三区软件 | 日韩av在线免费 | 国产一区 | 国产第一页在线观看 | 99精品久久久国产一区二区三 | 亚洲国产成人精品女人久久久 | 婷婷色成人| 欧美日韩亚洲一区 | 久久精彩视频 | 亚洲精品视频在线播放 | 男人的天堂在线视频 | 国产一区| 欧美性影院 | 一区二区三区免费观看 |