关于UIScrollView不能拖动的问题

今天在项目中代码添加了UIScrollView,

self.scrollView=[[UIScrollView alloc]init];
self.scrollView.canCancelContentTouches=YES;
self.scrollView.scrollEnabled=YES;
self.scrollView.showsHorizontalScrollIndicator=YES;
self.scrollView.userInteractionEnabled=YES;

接着在scrollView中添加了三个UIView将其布满,切换横屏竖屏时自动改变frame,肯定contentSize比frame.size大,可运行时,以为时添加的view覆盖了scrollView导致接受不到手指滑动的事件,于是将添加view的代码注释,scrollView还是不能拖动.网上各种百度各种纠结,没找到答案.后来发现在该view的controller中添加view时使用的代码是

[self.view addSubview:view],无奈试着将其改为

self.view =view,运行时能够拖动

 

原因不明,望大牛指教

posted on 2013-10-26 20:43  ChingyZhang  阅读(908)  评论(0编辑  收藏  举报

导航