显示UITextView滚动条指示器 - flashScrollIndicators不工作

时间:2015-02-21 08:12:03

标签: ios uiscrollview ios8 uitextview scrollbar

我尝试使用flashScrollIndicators方法在视图出现时至少闪烁scrollBar指示符,我试图直接调用它,并将其定义为函数并调用它,似乎没有任何工作。我错过了什么?!
我有一个名为scroll1的ScrollView,其中包含一个subView,其中包含我需要在scrollBars上显示的textViews(leftTextView和rightTextView),这里是我的代码片段,以便进一步说明:

     CGFloat x = counter * 1024;
            subView = [[UIScrollView alloc]initWithFrame:CGRectMake(x, 0, 1024, 693)];
            subView.clipsToBounds = NO;

            UIImage *img;
            UIImage *img2;


            img = [imgs objectAtIndex:i];
            img2 = [imgs objectAtIndex:i+1];


            imageView = [[UIImageView alloc ] initWithImage:img];
            imageView.frame = CGRectMake(i * 512, 0, 512, 693);
            imageView2 = [[UIImageView alloc ] initWithImage:img2];
            imageView2.frame = CGRectMake((i+1) * 512, 0, 512, 693);
            rightTextView = [[UITextView alloc]init];
            leftTextView = [[UITextView alloc]init];

  [rightTextView setFont:[UIFont boldSystemFontOfSize:fontSize]];
            rightTextView.editable = NO;
            leftTextView.editable = NO;

            rightTextView.layer.zPosition = 2;
          //  [leftTextView becomeFirstResponder];
            leftTextView.layer.zPosition = 2;
        //    [self flashScrollIndicators];

            if(i == 4) {
                leftTextView.frame = CGRectMake(2090, 0, 500,300);
                //[self flashScrollIndicators];
              //  [leftTextView flashScrollIndicators];

                //  NSLog(@"Z Position %f", leftTextView.layer.zPosition);


            }
            else if(i == 6){
                leftTextView.frame = CGRectMake(3120, 450, 480,250);
                rightTextView.frame = CGRectMake(3584, 0, 500,200);

            }
            else if(i==8){
                leftTextView.frame = CGRectMake(4144, 0, 470,280);
                rightTextView.frame = CGRectMake(4608, 450, 500,220);

            }
            else if(i==10){
                leftTextView.frame = CGRectMake(5168, 0, 500,300);
                rightTextView.frame = CGRectMake(5646, 0, 480,300);


            }
            else if(i==12){
                leftTextView.frame = CGRectMake(6192, 0, 470,300);
                rightTextView.frame = CGRectMake(6638, 430, 500,250);

            }
            else if(i==14) {
                leftTextView.frame = CGRectMake(7216, 420, 430,280);
                rightTextView.frame = CGRectMake(7680, 0, 500,280);


            }

            else if(i==16) {
                leftTextView.frame = CGRectMake(8240, 0, 470,300);
                rightTextView.frame = CGRectMake(8674, 0, 500,400);

            }
            else if(i==18){
                leftTextView.frame = CGRectMake(9264, 410, 470,280);
                rightTextView.frame = CGRectMake(9728, 0, 500,250);


            }
            else if(i==20){
                leftTextView.frame = CGRectMake(10260, 320, 470,350);
                rightTextView.frame = CGRectMake(10752, 450, 500,300);

            }
            else if(i==22){
                leftTextView.frame = CGRectMake(11312, 0, 500,300);
                rightTextView.frame = CGRectMake(11776, 0, 500,300);

            }
            rightTextView.backgroundColor = [UIColor clearColor];
            rightTextView.textColor = [UIColor blackColor];
          //  rightTextView.scrollIndicatorInsets = UIScrollViewIndicatorStyleWhite ;



            [rightTextFieldsArray addObject:rightTextView];

            leftTextView.backgroundColor = [UIColor clearColor];
            leftTextView.textColor = [UIColor blackColor];
          //  leftTextView.text = leftArray[i/2];
            NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
            paragraphStyle.lineHeightMultiple = 32.0f;
            paragraphStyle.maximumLineHeight = 32.0f;
            paragraphStyle.minimumLineHeight = 32.0f;
            // NSString *string = @"if you want reduce or increase space between lines in uitextview ,you can do this with this,but donot set font on this paragraph , set this on uitextveiw.";

            NSDictionary *ats = @{
                                  NSParagraphStyleAttributeName : paragraphStyle,
                                  };

            //  [lefTextView setFont:[uifont fontwithname:@"Arial" size:20.0f]];
            leftTextView.attributedText = [[NSAttributedString alloc] initWithString:leftArray[i/2] attributes:ats];
             [leftTextView setFont:[UIFont boldSystemFontOfSize:fontSize]];

            rightTextView.attributedText = [[NSAttributedString alloc] initWithString:rightArray[i/2] attributes:ats];
            [rightTextView setFont:[UIFont boldSystemFontOfSize:fontSize]];

         //   [leftTextView flashScrollIndicators];

            [leftTextFieldsArray addObject:leftTextView];
            subView.scrollEnabled = NO;
            subView.userInteractionEnabled = NO;

            [subView addSubview:imageView];
            [imageView2 removeFromSuperview];

           // [leftTextView removeFromSuperview];
            [self.scroll1 addSubview:leftTextView];
            [self.scroll1 addSubview:rightTextView];
            [self.scroll1 addSubview:subView];

0 个答案:

没有答案