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

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

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

問題描述

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

[myscrollView flashScrollIndicators];

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

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

解決方案

Apple 間接不鼓勵在其

  • 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 在滾動時暫停 NSTimer)
    主站蜘蛛池模板: 亚洲高清在线观看 | 97精品国产一区二区三区 | www.日韩高清 | 成人h电影在线观看 | 久久av影院 | 伊人超碰| 一级毛片在线播放 | 久久99精品久久久 | k8久久久一区二区三区 | 亚洲乱码一区二区三区在线观看 | 成人欧美一区二区三区黑人孕妇 | 精品国产高清一区二区三区 | 国产激情 | 亚洲欧美一区二区三区视频 | 夜夜艹 | 亚洲综合首页 | 日韩在线一区二区三区 | 在线观看亚 | 亚洲综合色丁香婷婷六月图片 | 久久精品一二三影院 | 精品国产一区二区三区性色av | 91精品欧美久久久久久久 | 九九久久精品 | 亚洲国产成人精品女人久久久 | 成人在线观看欧美 | 成人三级av | a级黄色片在线观看 | 亚洲一区中文字幕 | 中文字幕第一页在线 | 亚洲一区二区三区视频在线 | 久久精品电影 | 五月婷婷丁香 | 欧美午夜精品 | av片免费 | aaa在线观看| 看片国产| 国产 欧美 日韩 一区 | 久久999 | 自拍偷拍中文字幕 | 日韩视频―中文字幕 | 日本小电影网站 |