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

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

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

問題描述

我需要在 viewDidLoad 上創(chuàng)建一個(gè)始終可見的滾動條,以便用戶可以了解有要滾動的內(nèi)容.我做了以下事情:

[myscrollView flashScrollIndicators];

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

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

解決方案

Apple 間接不鼓勵(lì)在其

  • UIScrollView 指示器總是顯示?
  • 滾動指示器可見性
  • 使?jié)L動條在 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

    這篇關(guān)于讓滾動條在 UIScrollView 上始終可見?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)
    Photos app-like gap between pages in UIScrollView with pagingEnabled(使用 pagingEnabled 的 UIScrollView 中頁面之間的照片應(yīng)用程序式間隙)
    why UIScrollView is leaving space from top in ios 6 and ios 7(為什么 UIScrollView 在 ios 6 和 ios 7 中從頂部留下空間)
    UIScrollView pauses NSTimer while scrolling(UIScrollView 在滾動時(shí)暫停 NSTimer)
    主站蜘蛛池模板: 九九在线 | 久久精品亚洲成在人线av网址 | 日韩精品一区二区三区在线观看 | 婷婷桃色网 | 中文字幕一区二区三区精彩视频 | 欧美日本免费 | 久久一级大片 | 五月天天丁香婷婷在线中 | 精品久久影院 | 91欧美精品 | 中文在线播放 | 欧美日韩视频在线 | 久久不射电影网 | 国产探花在线精品一区二区 | 天天爱天天操 | 午夜影院在线播放 | 国产不卡一区 | 国产丝袜人妖cd露出 | 久久精品国产亚洲一区二区 | 九九热精品在线 | 免费福利视频一区二区三区 | 亚洲一区二区三区在线视频 | 99这里只有精品视频 | 欧美福利视频 | 日韩视频中文字幕 | 欧美专区在线 | 久久精品av | 国产wwwcom | 欧美色图综合网 | 天天干狠狠干 | 久久久免费电影 | av午夜激情| 99久久精品免费看国产小宝寻花 | 密色视频 | 黄色在线观看网址 | 99精品视频在线观看 | 在线国产一区二区 | 久久国产精品一区二区三区 | 一区二区三区免费 | 亚洲一区二区三区在线视频 | 国产精品久久久久久久久久了 |