简体   繁体   English

将UIWebView嵌入UIScrollView有多糟?

[英]How bad is it to embed UIWebView in UIScrollView?

So Apple is saying that UIWebView and UITableView objects shouldn't be embedded in UIScrollView objects. 所以苹果公司说UIWebView和UITableView对象不应该嵌入UIScrollView对象中。 https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIWebView_Class/index.html https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIWebView_Class/index.html

You should not embed UIWebView or UITableView objects in UIScrollView objects. 您不应在UIScrollView对象中嵌入UIWebView或UITableView对象。 If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled. 如果这样做,可能会导致意外行为,因为两个对象的触摸事件可能会混合在一起并且处理不当。

Does that mean we should never have web or table views inside scroll views? 这是否意味着我们永远不应该在滚动视图中包含Web视图或表格视图? I'm implementing an app that have several web views and table views that scroll with the rest of the content of the view, so scrolling in the web and table views is disabled. 我正在实现一个具有多个Web视图和表视图的应用程序,这些视图随视图的其余内容一起滚动,因此将禁用Web和表视图的滚动。

To never place web or table views inside scroll views would mean big design changes. 永远不要将Web视图或表视图放置在滚动视图中,这将意味着重大的设计更改。 Is Apple saying that we should never keep web and table views inside scroll views, meaning we can never have them scroll with the rest of the view's content? 苹果说我们应该永远保持网络和表视图滚动视图内,这意味着我们可以永远让他们与视图的其余内容滚动?

Or will it work OK as long as scrolling is disabled for the web and table view embedded in the scroll view? 还是只要禁用滚动视图中嵌入的Web和表格视图的滚动功能,就可以正常工作吗? If not - are there any better alternatives other than redesigning the app? 如果不是,除了重新设计应用程序之外,还有其他更好的选择吗?

I have used a UITableView inside a UIScrollView in a production app. 我在生产应用程序的UIScrollView中使用了UITableView

Example: 例:

List of POI's in a UITableView and MKMapView next to each other inside a UIScrollView with paging enabled. 在启用分页的UIScrollViewUITableViewMKMapView 中彼此相邻的POI列表。

The problem was indeed that the scrolling of the UIScrollView did not actually work. 问题确实是UIScrollView的滚动实际上并没有起作用。 Especially on the MKMapView , as this scrolls in all directions. 尤其是在MKMapView ,因为它可以全方位滚动 The workaround was to create a custom UIView with two UIButton 's which act as a custom UISegmentedControl . 解决方法是使用两个UIButton创建一个自定义UIView ,以用作自定义UISegmentedControl These will actually scroll the UIScrollView to the selected page . 这些实际上会将UIScrollView滚动到所选页面

Some of the things Apple puts in their documentation is probably there to be able to comment on bug reports, or to say: See, we told you so . 苹果公司在其文档中放入的某些内容可能是能够对错误报告进行评论,或者说: 看,我们是这样告诉您的

UIWebView ans UITableView inherit from a UIScrollView , so they will scroll if the content exceed the screen size. UIWebViewUITableView继承自UIScrollView ,因此如果内容超过屏幕大小,它们将滚动。 If you use it in a UIScrollView its a UIScrollView in an other. 如果你使用它在一个UIScrollView的一个UIScrollView在其他。 That's why it can cause problems. 这就是为什么它可能导致问题。

And if you want to use scrolling view in another, you should change the design of your app. 而且,如果要在其他视图中使用滚动视图,则应更改应用程序的设计。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM