UIScrollView中UITextView的可见文本,其中包含子视图UIImageView

时间:2014-06-29 10:13:04

标签: ios objective-c uiscrollview uiimageview uitextview

在UITextView中输入时,文字不可见; 完成输入后,文字不可见。

如何让它可见?

代码如下。我没有故意放置与UITextView相关的代码,因为只设置了字体和对齐属性。

// Setup the background image view.
[self.backgroundImageView setBackgroundColor:[UIColor blackColor]];
[self.view sendSubviewToBack:self.backgroundImageView];

// Set the image view.
CGRect r = CGRectMake(0, 0, self.TextView.bounds.size.width, 455);
ImageView = [[UIImageView alloc] initWithFrame:r];

// Set up the scroll view for the image zooming in/out and scrolling.
imgScrollView = [[UIScrollView alloc] initWithFrame:ImageView.bounds];

[imgScrollView setScrollEnabled:YES];
[imgScrollView setClipsToBounds:YES];
[imgScrollView addSubview:ImageView];
[imgScrollView setBackgroundColor:[UIColor clearColor]];
[imgScrollView setContentSize:ImageView.frame.size];
imgScrollView.maximumZoomScale = 5.0;
imgScrollView.delegate = self;

UITapGestureRecognizer *doubleTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(scrollViewDoubleTapped:)];
doubleTapRecognizer.numberOfTapsRequired = 2;
doubleTapRecognizer.numberOfTouchesRequired = 1;
[imgScrollView addGestureRecognizer:doubleTapRecognizer];

[imgScrollView sendSubviewToBack:self.TextView];

[self.view addSubview:imgScrollView];

更新

[imgScrollView addSubview:self.TextView];

上面的代码解决了这个问题。

0 个答案:

没有答案