Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 02-17-2009, 08:09 PM   #5 (permalink)
bullale
Registered Member
 
Join Date: Feb 2009
Posts: 6
Default

I am going to attach an application that I made. It passes touches in UIScrollView to subviews.

Using IB, I made the following:

Window
-View
--UIScrollView
---UIView (*contentView)
----MyImageView
----UIButton

I had to make the AppDelegate the UIScrollView delegate. Within the AppDelegate I implemented the zoom view method.
Code:
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
	return contentView;
}
Since the UIImage and UIButton are subviews of the UIView, they scroll and zoom together.

UIButton's touch up inside method can be linked to an IBAction. In this case I linked it to a method in the appDelegate that prints an NSLog line.

I had to subclass UIImageView (MyImageView) to implement a touches method:
Code:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
	NSLog(@"ImagePressed");
}
I had to check UserInteractionEnabled for the contentView, MyImageView, and the UIButton.

Note however that I did not have to use ThirtyOne's code. I did not have to subclass UIScrollView. It seems as though the documentation is telling the truth in that UIScrollView passes touches to the subviews by default. (Look for touchesShouldBegin in the documentation).

Also note that touches are passed immediately when zoomed all the way out (no scrolling possible). But when zoomed in some, touches only pass after a short delay (to make sure the touch isn't a scroll).

I made this with IB in 10 minutes. I am trying to get this to work using view controllers and programming my view hierarchy manually, but have not been successful yet.
bullale is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,673
Threads: 89,155
Posts: 380,387
Top Poster: BrianSlick (7,110)
Welcome to our newest member, rockystdr
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:52 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.