Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 02-17-2009, 07: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
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 24,358
Threads: 39,155
Posts: 171,642
Top Poster: smasher (2,577)
Welcome to our newest member, jeffry7robbins
Powered by vBadvanced CMPS v3.1.0

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