Reputation: 1
My first view PageView.m like this
PageView.m
albumListView = [[AlbumListView alloc] initWithFrame:CGRectMake(0, 0, 45, 480)];
albumListView.tag = 1001;
[self addSubview:albumListView];
albumListView.hidden = YES;
[albumView release];
I want when my CameraView moved set albumListView.hidden = NO. How to do it!
CameraView.m
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
}
How to use delegate or other ways? Thank you!
Upvotes: 0
Views: 79
Reputation: 8914
Assuming that PageView
class is where the CameraView
instance is created, you can do sthg like this:
In your CameraView
class, define a protocol like this:
@class CameraView;
@protocol CameraViewDelegate <NSObject>
@optional
- (void)cameraViewMoved:(CameraView *)view;
@end
Then, in the same class implement a property to hold your delegate:
@property (nonatomic, assign) id<CameraViewDelegate> delegate;
In your CameraView implementation file, call your delegate's cameraViewMoved method when you want to notify it, like this:
if ([self.delegate respondsToSelector:@selector(cameraViewMoved:)]) {
[self.delegate cameraViewMoved:self];
}
Make your PageView
class a delegate of your CameraView
, by putting sthg like this in your PageView.h file:
@interface PageView : <CameraViewDelegate>
And in PageView.m class, first set yourself as the delegate of your cameraView by doing sthg like cameraView.delegate = self;
Then, implement the protocol method cameraViewMoved
. Inside this method, you can do what you need.
Upvotes: 1