iPhone:启用UIScrollView分页且没有缩放和预览 [英] iphone: UIScrollView Paging enabled with NO ZOOM and NO PREVIEW

查看:126
本文介绍了iPhone:启用UIScrollView分页且没有缩放和预览的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现一个启用了分页的UIScrollView,我可以浏览一些图像.那就是我现在想做的所有事情.

i want to implement a UIScrollView where paging is enabled and i can just flick through some images. Thats all i want to be able to do for now.

到目前为止,我已经在界面生成器中做到了这一点:有人可以帮忙吗?

I have done this so far in interface builder: can someone help?

剩下的我不知道该怎么办.有人可以帮我这个忙吗?我不需要任何缩放功能.我不希望滚动视图中的上一个或下一个图像有任何预览,我只想要一个简单的启用分页的滚动视图,该滚动视图允许用户浏览图像.

I dont know how to do the rest. Can someone please help me with this. I dont need any zooming functionality. I dont want any preview of the previous or next image within the scrollview, i just want a simple paging enabled scroll view that allows a user to flick through images.

感谢所有帮助. 如果您能一步一步告诉我如何实现这一目标,将不胜感激.谢谢.

All help is appreciated. If you could tell me step by step how i could achieve this that would be most appreciated. thank you.

我看过代码示例,它们只是具有太多的复杂性. Ive从一开始就看了几个,并且更喜欢教程.谢谢

I've looked at code examples and they just have too much complexity going on. Ive looked at several and prefer a tutorial from the beginning. thank you

推荐答案

听起来像您只需要将内容添加为UIScrollView的子视图并添加手势识别器即可.

Sounds like you just need to add your content as a subview of the UIScrollView and add a gesture recognizer.

将图像加载到UIImageView中.将UIImageView添加为UIScrollView的子视图.

Load your image into a UIImageView. Add the UIImageView as subview of the UIScrollView.

// do this in init or loadView or viewDidLoad, wherever is most appropriate
// imageView is a retained property
self.imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image1.png"];
[scrollView addSubview:imageView];

将UISwipeGestureRecognizer添加到UIScrollView.

Add a UISwipeGestureRecognizer to the UIScrollView.

// probably after the code above
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:);
[scrollView addGestureRecognizer:swipe];
[swipe release];

在UISwipeGestureRecognizer处理程序上,在UIImageView中更改已加载的图像.

On the UISwipeGestureRecognizer handler, change the loaded image in the UIImageView.

- (void)handleSwipe:(UIGestureRecognizer *)swipe {
  // do what you need to determine the next image
  imageView.image = [UIImage imageNamed:<your replacement image here>];
}

这篇关于iPhone:启用UIScrollView分页且没有缩放和预览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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