Just modify your class like below: implementation longGestureViewController // Implement loadView to create a view hierarchy programmatically, without using a nib. - (void)loadView { UIView *view = UIView alloc initWithFrame:UIScreen mainScreen. ApplicationFrame; self.
View = view; self.view. Tag = 100; view release; mImageView1 = UIImageView alloc initWithFrame:CGRectMake(10.0, 10.0, 100.0, 120.0); mImageView1. Image = UIImage imageNamed:@"tile07.
Png"; self. View addSubview:mImageView1; mImageView1. UserInteractionEnabled = YES; mImageView1.
Tag = 1; mImageView1 release; mImageView2 = UIImageView alloc initWithFrame:CGRectMake(120.0, 10.0, 100.0, 120.0); mImageView2. Image = UIImage imageNamed:@"tile08. Png"; mImageView2.
UserInteractionEnabled = YES; mImageView2. Tag = 2; self. View addSubview:mImageView2; mImageView2 release; mImageView3 = UIImageView alloc initWithFrame:CGRectMake(10.0, 140.0, 100.0, 120.0); mImageView3.
Image = UIImage imageNamed:@"tile09. Png"; mImageView3. Tag = 3; mImageView3.
UserInteractionEnabled = YES; self. View addSubview:mImageView3; mImageView3 release; } // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { super viewDidLoad; UILongPressGestureRecognizer *longPress = UILongPressGestureRecognizer alloc initWithTarget:self action:@selector(longPressed:); mImageView1 addGestureRecognizer:longPress; longPress release; longPress = UILongPressGestureRecognizer alloc initWithTarget:self action:@selector(longPressed:); mImageView2 addGestureRecognizer:longPress; longPress release; longPress = UILongPressGestureRecognizer alloc initWithTarget:self action:@selector(longPressed:); mImageView3 addGestureRecognizer:longPress; longPress release; } -(void)longPressed:(UILongPressGestureRecognizer *)sender { CGPoint location = sender locationInView:self.
View; UIView *view = self. View hitTest:location withEvent:UIEventTypeTouches; NSLog(@"%d", view. Tag); } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview.
Super didReceiveMemoryWarning; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g.Self.
MyOutlet = nil; } - (void)dealloc { super dealloc; }.
Just modify your class like below: @implementation longGestureViewController // Implement loadView to create a view hierarchy programmatically, without using a nib. - (void)loadView { UIView *view = UIView alloc initWithFrame:UIScreen mainScreen. ApplicationFrame; self.
View = view; self.view. Tag = 100; view release; mImageView1 = UIImageView alloc initWithFrame:CGRectMake(10.0, 10.0, 100.0, 120.0); mImageView1. Image = UIImage imageNamed:@"tile07.
Png"; self. View addSubview:mImageView1; mImageView1. UserInteractionEnabled = YES; mImageView1.
Tag = 1; mImageView1 release; mImageView2 = UIImageView alloc initWithFrame:CGRectMake(120.0, 10.0, 100.0, 120.0); mImageView2. Image = UIImage imageNamed:@"tile08. Png"; mImageView2.
UserInteractionEnabled = YES; mImageView2. Tag = 2; self. View addSubview:mImageView2; mImageView2 release; mImageView3 = UIImageView alloc initWithFrame:CGRectMake(10.0, 140.0, 100.0, 120.0); mImageView3.
Image = UIImage imageNamed:@"tile09. Png"; mImageView3. Tag = 3; mImageView3.
UserInteractionEnabled = YES; self. View addSubview:mImageView3; mImageView3 release; } // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { super viewDidLoad; UILongPressGestureRecognizer *longPress = UILongPressGestureRecognizer alloc initWithTarget:self action:@selector(longPressed:); mImageView1 addGestureRecognizer:longPress; longPress release; longPress = UILongPressGestureRecognizer alloc initWithTarget:self action:@selector(longPressed:); mImageView2 addGestureRecognizer:longPress; longPress release; longPress = UILongPressGestureRecognizer alloc initWithTarget:self action:@selector(longPressed:); mImageView3 addGestureRecognizer:longPress; longPress release; } -(void)longPressed:(UILongPressGestureRecognizer *)sender { CGPoint location = sender locationInView:self.
View; UIView *view = self. View hitTest:location withEvent:UIEventTypeTouches; NSLog(@"%d", view. Tag); } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview.
Super didReceiveMemoryWarning; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g.Self.
MyOutlet = nil; } - (void)dealloc { super dealloc; }.
This was a part of the solution I was looking for. However I'm also searching for a way to put the image from the scroller to the main view. I tried this by using "image1 addSubview:self.
View; However I get the error "Data Formatters temporarily unavailable, will re-try after a 'continue'". Help is greatly appreciated – BarryK88 Mar 22 at 12:30 You are trying to addSubView self. View to image1 so it is giving error.
– ypk Mar 22 at 13:06 Can you also explain me why, and what the next thinking steps are? – BarryK88 Mar 22 at 13:11 Look into my answer now, I have implemented entire class for you. – ypk Mar 22 at 13:21 Wow, many thanks for your effort!
However when I declare my View with the statement "UIView *view = UIView alloc initWithFrame:UIScreen mainScreen. ApplicationFrame;" my entire app disappears from screen. I think I need an easier solution for bringing the images in front so that I would be able to apply a drag functionality.(I only declared my images within my headerfile like 'IBOutlet UIImageView *image1;') Hope you can still help me out.
– BarryK88 Mar 22 at 14:00.
I did succeeded implementing the two gesturerecognizers. So the images within my scroller are now draggable. However it limits itself inside the scrollview.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.