当您实际滚动到下一页时,我试图重现滚动视图的平滑动画,并启用分页.它似乎是UIViewAnimationCurveEaseInOut,但我需要一个"下一页"按钮并以编程方式触发滚动.
这是我的代码:
-(void) scrollToPage:(int)page
{
UIScrollView *scrollView = contentView;
CGPoint offset = CGPointMake(scrollView.bounds.size.width * page, scrollView.contentOffset.y);
[scrollView setContentOffset:offset animated: YES];
[self pageControlUpdate];
}
-(void) scrollToNextPage
{
[self scrollToPage:(pageControl.currentPage + 1)];
}
Run Code Online (Sandbox Code Playgroud)
我无法重现平滑UIViewAnimationCurveEaseInOut,无论是用setContentOffset还是用scrollRectToVisible......它都会带着丑陋的线性动画进入下一页
我甚至尝试手动设置动画:
[UIView animateWithDuration:.5 delay:0 options:UIViewAnimationCurveEaseInOut animations:^{
scrollView.contentOffset = offset;
} completion:^(BOOL finished) { } ];
Run Code Online (Sandbox Code Playgroud)
我哪里错了?
我有一个随机的问题,当我提出UIImagePickerController捕捉照片.有时预览屏幕只是黑色.(这可能是第一次,可能是第二次,或者可以永远,甚至永远不会).然而,我可以看到相机控制,黄色方块可以进行人脸检测.如果我等待一段时间(约20秒),黑色预览消失,预览出现......
以下是我有时可以在日志中看到的内容:
快照未呈现的视图会导致空快照.确保在屏幕更新后快照或快照之前至少渲染了一次视图.
config:xcode 5.1.1,iPhone 5/5S,ios 7.0/7.1
这是一个为我重现问题的代码:
-(void) showCamera
{
UIImagePickerController *pickerController = [[UIImagePickerController alloc] init];
pickerController.allowsEditing = NO;
pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
pickerController.cameraDevice = UIImagePickerControllerCameraDeviceFront;
pickerController.cameraOverlayView = nil;
UIViewController *topController = [UIApplication sharedApplication].keyWindow.rootViewController;
while (topController.presentedViewController) {
topController = topController.presentedViewController;
}
[topController presentViewController:pickerController animated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)
当然,对于我的真实应用程序,我测试是否有相机:
[UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]);
Run Code Online (Sandbox Code Playgroud)
我发现了几个类似的问题,但没有任何真正的答案:
我已经尝试了他们的建议,没有成功.
编辑:这里有一些代码:正如所说的,我创建了一个单例类,子类化UIImagePickerController:
@implementation BBImagePickerController
static BBImagePickerController *sharedInstance = nil;
+ (BBImagePickerController *) sharedInstance
{
if (!sharedInstance)
sharedInstance = [[BBImagePickerController alloc] init];
return sharedInstance;
} …Run Code Online (Sandbox Code Playgroud)