无法在UIPageViewController中使用UITextview [英] Cannot Impliment UITextview inside a UIPageViewController

查看:105
本文介绍了无法在UIPageViewController中使用UITextview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的问题,我有一个页面应用程序,其中一个页面我使用了 UITextView ,但当我点击 UITextView时它移动到下一页,不能写任何东西。

I have a strange issue , I have a page app in which one page I had used a UITextView, but when I tap on the UITextView it moves to the next page, can't write anything on it.

使用 UIPageViewControllerTransitionStylePageCurl 时没有问题。唯一的问题是 UIPageViewControllerTransitionStyleScroll 。有人知道解决方案吗?请帮帮我

There is no issue when I use UIPageViewControllerTransitionStylePageCurl. The only issue is with UIPageViewControllerTransitionStyleScroll. Anyone know the solution? please help me

推荐答案

我自己遇到了同样的问题,看来这是每当发生一些默认行为的结果 UITextField UITextView 成为 UIScrollView 中的第一响应者。

I ran into the same issue myself, and it appears that it's a consequence of some default behavior that occurs whenever a UITextField or UITextView becomes first responder inside a UIScrollView.

阻止 UITextView 滚动 UIPageViewController 的解决方案是先将其嵌入 UIScrollView 而不是直接进入页面的主视图。

The solution to prevent your UITextView from scrolling the UIPageViewController is to first embed it into a UIScrollView instead of directly into a page's main view.

这是有效的,因为当 UITextView 成为第一个时响应者它将在视图层次结构中搜索 UIScrollView 类型中最早的超级视图,并且它将滚动该滚动视图以适应覆盖屏幕的键盘。如果未将 UITextView 包装在 UIScrollView 中,则将选择 UIPageViewController 的内部 UIScrollView ,滚动,产生不良行为。

This works because when the UITextView becomes first responder it will search for the earliest superview in the view hierarchy that is of type UIScrollView, and it will scroll that scrollview to accommodate for the keyboard covering the screen. If you don't wrap the UITextView inside a UIScrollView, your UIPageViewController's internal UIScrollView will be chosen and scrolled, producing undesired behavior.

这篇关于无法在UIPageViewController中使用UITextview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆