What I want is that, on top of pdf view I want to add an image (one or more than 1 image). Once I add from some button, it has to come(appear) on pdf view to any location, and based on my choice I can able to drag/move that image on any location/position on the pdf view.
What I tried:
Example1: I took one ViewController and and added one imageView programatically on the view. And using some touch event method I can easily move/drag the image anywhere on the view
and here is the code for this,
#import "ViewController.h"
@interface ViewController ()
{
UIImageView * imageview;
CGRect frame;
}
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
CGRect myImageRect = CGRectMake(100, 100, 200, 35);
self->imageview = [[UIImageView alloc] initWithFrame:myImageRect];
[self->imageview setImage:[UIImage imageNamed:@"signer"]];
[self.view addSubview:self->imageview];
}
- (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event {
UITouch *touch = [[event allTouches] anyObject];
//CGPoint touchLocation = [touch locationInView:touch.view];
CGPoint touchLocation = [touch locationInView:touch.view];
CGRect frame = [self.view convertRect:self->imageview.frame fromView:self.view];
NSLog(@"touchesMoved %@", CGRectCreateDictionaryRepresentation(frame));
if ([touch.view isEqual: self.view]) {
self->imageview.center = touchLocation;
return;
}
}
@end
What I Wants to achieve:
Example2: I took one ViewController, and I added pdf view on that. Similarly I added one imageView on pdfView. When I tried to drag/move that imageView its not moving like it is working in example1.
How I can achieve that moving/drag the imageView on pdfView? Anyone can help me please.
Problem is that
imageview
added below thescrollview of pdfview
. other issue moveimageView
not moving likeexample 1
becausepdfView
containscrollview
so when you touch onpdfview
it calls gesture ofpdfview
nottouchesMoved
method declare inViewController
.Solution:
add this line in
viewDidLoad
add this line in
preparePDFViewWithPageMode
method at lastReplace in `touchMoved'