久久久久久久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)
    主站蜘蛛池模板: 久久精品黄色 | 国产精品无码久久久久 | 天天躁日日躁狠狠很躁 | 成人性生交大片 | 成人久久18免费网站麻豆 | 日韩中文电影 | 少妇久久久 | 久久久久久久一级 | 特级生活片 | 激情视频中文字幕 | 亚洲国产高清高潮精品美女 | 精品国产乱码久久久久久a丨 | 色婷婷一区二区三区四区 | 天天色官网 | 欧美视频一区 | 国产精品女人久久久 | 久久精品视频91 | 精品伊人| 国产精品国产成人国产三级 | 欧洲在线视频 | 国产精品久久久久影院色老大 | 午夜精品福利视频 | 欧美一级视频在线观看 | 拍真实国产伦偷精品 | 女生羞羞视频 | 有码在线 | 99久久婷婷国产综合精品电影 | 永久看片| 成人在线播放网址 | 国产h视频| av看片| 亚洲综合国产 | 精品欧美一区二区三区久久久 | 免费一级欧美在线观看视频 | 亚洲精品一区二区三区在线 | 天堂视频中文在线 | 国产伦精品一区二区三区高清 | 久久久久久亚洲精品 | 欧美自拍一区 | 日韩中文一区二区三区 | 国产黄色av网站 |