UIView不触发UIScrollView委托中的方法 [英] UIView not firing methods in the UIScrollView delegate

查看:56
本文介绍了UIView不触发UIScrollView委托中的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人可以阐明为什么UIScrollView委托中的任何方法都不会被触发.

I wonder if someone could please shed some light as to why any of the methods in UIScrollView delegate are not being fired.

设置场景.我有一个UIViewController被推到堆栈上.在此视图中,我有5个自定义标签.每次轻按一次,我都会从UIViewController/xib组合中加载5个视图(每个选项卡一个)的功能.

To set the scene. I have a UIViewController which is pushed onto a stack. On this view I have 5 custom tabs that I have made. On a tap of each tap I have a function with loads of 5 views (one per tab) from UIViewController/xib combo.

ExercisePhotoView *exercisePhotoView = [[ExercisePhotoView alloc] initWithNibName:@"ExercisePhotoView" bundle:nil];
exercisePhotoView.exercise = self.exercise;
[self.photoView addSubview:exercisePhotoView.view];
[exercisePhotoView release];

在加载的这些视图之一中,我有一个滚动视图,其中包含一些图像(上面的代码块是所说的视图). self.exercise 是一个NSManagedObject.图像可以很好地加载到scrollview控制器中,并且分页可以正常工作.但是不起作用的是任何ScrollView的委托方法,例如

On one of these views that gets loaded I have a a scroll view with some images in (the above code block is the said view). The self.exercise is an NSManagedObject. The images are loaded fine into the scrollview controller and the paging works. What however does not work is any of the ScrollView's delegate methods such as

- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)theScrollView

我已经在我的头文件中包括了对委托的引用.

I have included a reference to the delegate in my header file like so.

@interface ExercisePhotoView : UIViewController <UIScrollViewDelegate> {
    IBOutlet UIScrollView   *scrollView;
    IBOutlet UIPageControl  *pageControl;

    Exercise                *exercise;
    NSMutableArray          *exerciseImageList; 
}

是否存在我遗漏或做错的事情.我无法在 ExercisePhotoView 类上触发任何委托方法.

Is there something that I am missing or doing wrong. I cannot get any of the delegate methods to fire on the ExercisePhotoView class.

谢谢.

推荐答案

您必须将 self.scrollView.delegate 设置为应作为scrollView委托的对象.

You have to set self.scrollView.delegate to the object that should act as a delegate to the scrollView.

这篇关于UIView不触发UIScrollView委托中的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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