【发布时间】:2011-03-24 23:10:44
【问题描述】:
大家好,我对 uiscrollview 有疑问。 当我按下按钮通过 UIView 动画更改 contentOffset scollview 时,我有这样的东西:
NSLog(@"%@\n %f %f", scroll, scroll.contentOffset.x, scroll.contentOffset.y);
[UIView beginAnimation:@"anima" context:nil];
[UIView setAnimationDuration:0.5];
scroll.contentOffset = CGPointMake(0,index * scroll.frame.size.height;
[UIView commitAnimations];
NSLog(@"%@\n %f %f", scroll, scroll.contentOffset.x, scroll.contentOffset.y);
在这些指令更改之前和之后创建一个日志 cotentOffSet,显然滚动视图是一个现有实例,因此它与 nil 不同。
问题是屏幕不会改变不移动的偏移滚动视图。
我在代码的其他部分和其他滚动视图中做同样的事情,但它工作得很好。
我也试过了:
[scroll setContentOffset:CGPointMake(0, index * currentVerticalScrollView.frame.size.height) animated:YES] ;
但也不会改变!
为什么它不起作用?
【问题讨论】:
-
你当时确定在主线程吗?
标签: iphone objective-c ios ipad uiscrollview