簡體   English   中英

iOS 8自定義鍵盤UIScrollview無法正常工作

[英]iOS 8 Custom keyboard UIScrollview isn't working

我試圖在自定義鍵盤視圖中添加UISchollView,但它顯示視圖但不滾動。 這是我的代碼。 我也嘗試過self.view,但也不起作用。

UIScrollView *scrollview1 = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 216)];
    NSInteger viewcount= 8;
    for (int i = 0; i <viewcount; i++)
    {
        CGFloat y = i * 50;
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, y,50, 50)];
        view.backgroundColor = (i%2==0)?[UIColor greenColor]:[UIColor blueColor];
        [scrollview1 addSubview:view];
    }
    scrollview1.contentSize = CGSizeMake(self.view.frame.size.width, self.view.frame.size.height *viewcount);
    scrollview1.backgroundColor = [UIColor redColor];
    scrollview1.pagingEnabled=YES;
    [self.inputView addSubview:scrollview1];

在此處輸入圖片說明

如果UIScrollViewcontentSize大於其框架大小,則將滾動。 因此,請嘗試設置其contentSize屬性,並檢查是否啟用了userInteraction

希望它能工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM