Set UIScrollView delegate to it's own custom class

I created a custom component from UIScrollView.

I create a custom UIScrollview class and add it to my scroll view.

And in the custom class in "- (void)drawRect:(CGRect)rect" I design my scroll view the way I wanted. and its all working fine.

My Question is how to add my scrollview as the delegate of the Custom class.

I did this inside my custom class -

self.delegate = self;

and the delegate get set and I have access to the UIScroll view delegate methods (like - - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView).

My problem is once I set my delegate like 'self.delegate = self;' compiler gives me a warning like below

Please can anyone help me to fix this warning.

Answers


You need to declare your custom class as conforming to the UIScrollViewDelegate protocol.

Check out the Apple docs on protocols.

In your header file, you probably have something like

@interface OGOTimeSelector : UIScrollView

To declare that your class conforms to the UIScrollViewDelegate protocol, this would become:

@interface OGOTimeSelector : UIScrollView <UIScrollViewDelegate>

Need Your Help

Severe keyboard lag in Angular app on mobile Safari/Chrome

javascript ios angularjs google-chrome safari

I am experiencing a severe keyboard lag in an Angular app running on mobile Safari and Chrome. There is no lag of any sort when typing on desktop browsers. How could I go about troubleshooting this...

Android Open Source (AOSP) build failure on Mac OS X: ld: symbol(s) not found for architecture x86_64

android xcode macos makefile android-source

So I'm attempting to build the AOSP master branch, following the Instructions here to the letter. I'm using Mac OS X 10.11, XCode 7.0.1, XCode Command Line Tools 7.0.1.