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

即使 contentSize 大于 frame 并且在設(shè)置內(nèi)容大小之前

scrollView doesn#39;t work even though contentSize is larger than frame and subview is added before setting content size(即使 contentSize 大于 frame 并且在設(shè)置內(nèi)容大小之前添加了子視圖,滾動(dòng)視圖也不起作用) - IT屋
本文介紹了即使 contentSize 大于 frame 并且在設(shè)置內(nèi)容大小之前添加了子視圖,滾動(dòng)視圖也不起作用的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

    - (void)viewDidLoad
{

[super viewDidLoad];




self.navigationController.navigationBar.translucent = YES;
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"sprites_0001_Rectangle-1.png"]  forBarMetrics:UIBarMetricsDefault];



self.navigationController.navigationBar.translucent = YES;

UIImageView *imageView = [[UIImageView alloc]init];
UIImage *image = [UIImage imageNamed:@"sprites_0000s_0008_1st-Page.png"];
imageView.image = image;


//imageView.translatesAutoresizingMaskIntoConstraints = NO;
imageView.backgroundColor = [UIColor clearColor];
self.view = imageView;



if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {

     //Write the code to set up view for iPad

   }else{

    UIScrollView *scrollView = [[UIScrollView alloc] init];
    scrollView.backgroundColor = [UIColor clearColor];
    scrollView.translatesAutoresizingMaskIntoConstraints = NO;

    [self.view addSubview:scrollView];
    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-40-[scrollView(==240)]"
                                                                      options:0
                                                                      metrics:nil
                                                                        views:NSDictionaryOfVariableBindings(scrollView)]];
    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-50-[scrollView(==468)]"
                                                                      options:0
                                                                      metrics:nil
                                                                        views:NSDictionaryOfVariableBindings(scrollView)]];

    UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"ParentsMock.png"]];
    imageView.translatesAutoresizingMaskIntoConstraints = NO;
    [scrollView addSubview:imageView];



    [scrollView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|[imageView(==1000)]|"
                                                                       options:0
                                                                       metrics:0
                                                                         views:NSDictionaryOfVariableBindings(imageView)]];
    [scrollView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[imageView(==2000)]|"
                                                                       options:0
                                                                       metrics:0
                                                                         views:NSDictionaryOfVariableBindings(imageView)]];

    }

這是我以編程方式創(chuàng)建 UIScrollView 的嘗試,但是即使在添加子視圖進(jìn)入 scrollView.

This is my attempt to create UIScrollView programmatically however I couldn't make the scrollView work even though I set the contentSize after adding the subview into the scrollView.

正如您在這張圖片中看到的,我使用 UINavigationController 來(lái)包裝 UIViewControllar 并將 UIImageView 設(shè)置為其視圖.我創(chuàng)建了一個(gè)滾動(dòng)視圖并將其添加到視圖頂部.然后我創(chuàng)建另一個(gè) imageView1 并將其插入到 scrollView 中.

As you can see in this picture, I use UINavigationController to wrap a UIViewControllar and set UIImageView as its view. the I created a scrollView and add it on top of the view. then I create another imageView1 and insert it into the scrollView.

請(qǐng)注意,整個(gè)視圖控制器的視圖是一個(gè)imageView,與我插入到scrollView中的imageView不同.

推薦答案

我找到了答案.看來(lái)我需要在 UIImageView 上啟用 userInteraction.記得當(dāng)我使用 UIImageView 作為視圖控制器的視圖時(shí).因此 UIImageView 的 userInteractionEnabled 屬性的默認(rèn)值為 NO.它根本不接受任何觸摸.我們需要像這樣啟用它

I found out the answer. It seems that I need to enable userInteraction on UIImageView. Remember when I use UIImageView as the view of the view controller. Therefore default value for userInteractionEnabled Property of UIImageView is NO. It ACCEPTS NO touches at all. We need we enable it like this

imageView.userInteractionEnabled = YES;

問(wèn)題已解決.

這篇關(guān)于即使 contentSize 大于 frame 并且在設(shè)置內(nèi)容大小之前添加了子視圖,滾動(dòng)視圖也不起作用的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

how to set scrollview content size in swift 3.0(如何在 swift 3.0 中設(shè)置滾動(dòng)視圖內(nèi)容大小)
Stop a UITableView from automatically scrolling(阻止 UITableView 自動(dòng)滾動(dòng))
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 模擬器上運(yùn)行時(shí),使用 iOS 6.0 SDK 并為 iOS 5 Target 構(gòu)建會(huì)導(dǎo)致 UIScrollView setMinimumZ
Create partial-screen UIPageViewController programmatically(以編程方式創(chuàng)建部分屏幕 UIPageViewController)
how to make an ImageView zoomable with or without ScrollView.?(如何使用或不使用 ScrollView 使 ImageView 可縮放?)
主站蜘蛛池模板: 成人免费大片黄在线播放 | 精品av| 国产精品中文在线 | 免费午夜剧场 | 二区av| 在线视频国产一区 | 成人深夜小视频 | 成人欧美一区二区三区在线观看 | 91色视频在线观看 | 久久精品无码一区二区三区 | 国产欧美日韩在线 | 激情一区二区三区 | 中文字幕在线观看国产 | 亚州综合在线 | 小h片免费观看久久久久 | 国产成人福利 | 久久国产福利 | 91久久精品| 成人免费区一区二区三区 | 看av网| 国产欧美在线播放 | 日韩三级一区 | 台湾a级理论片在线观看 | 日本久久久久久 | 超碰免费在线观看 | 国产精品久久久久久吹潮 | 日韩精品视频一区二区三区 | 国产一区二区三区四区 | 99资源 | 99re在线视频 | 日韩 欧美 二区 | 久久久久国产精品人 | 国产 日韩 欧美 在线 | 亚洲国产成人在线观看 | 一区二区三区免费 | 成人伊人网 | 精品国产精品三级精品av网址 | 中文字幕高清一区 | 精品九九九 | 欧美一区二不卡视频 | 国产一区二区免费在线 |