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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-30-2011, 07:02 PM   #1 (permalink)
kmt
Registered Member
 
Join Date: Oct 2011
Posts: 29
kmt is on a distinguished road
Default viewForZoomingInScrollView or pinchGesture?

Hi Forum,

I had the idea that I would make a class of ZoomView that would hold a .xib file containing buttons, text, images etc... that I want to scroll and zoom on. In doing some test code, I find very erratic behavior from viewForZoomingInScrollView: in the code below. It jumps, runs around the page and then when I let go, will no longer scroll.

This is a 'Blank' application and in the AppDelegate file for testing right now:

AppDelegate.h
Code:
@class ZoomView; // custom class with .xib file

@interface AppDelegate : UIResponder <UIApplicationDelegate, UIScrollViewDelegate> {
    UIView *innerview;
    ZoomView *zoomView;
}

@property (strong, nonatomic) UIWindow *window;

@end
AppDelegate.m
Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor blueColor];
    
    
    innerview = [[UIView alloc] initWithFrame:CGRectZero];
    
    zoomView = [[ZoomView alloc] initWithNibName:@"ZoomView" bundle:nil];
    [innerview addSubview:zoomView.view];
    
    CGRect aframe = CGRectMake(0, 100, 320, 200);
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:aframe];
    scrollView.contentSize = CGSizeMake(600, 400);
    scrollView.backgroundColor = [UIColor greenColor];
    scrollView.maximumZoomScale = 2;
    scrollView.minimumZoomScale = 0.25;
    scrollView.scrollEnabled = YES;
    scrollView.scrollsToTop = NO;
    scrollView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
    scrollView.delegate = self;
    [scrollView addSubview:innerview];
    [self.window addSubview:scrollView];
    
    
    [self.window makeKeyAndVisible];
    return YES;
}

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
    // NSLog(@"viewForZoomingInScrollView:");
    return innerview;
}
Should I be using a pinchGestureRecognizer instead? I just thought that this would be easier.

Does anyone have a good tutorial on the pinchGestureRecognizer for 4.2? I see in the objects > Gesture Recognizers that you can drag one of these onto your .xib file but, no idea how to hook it up from there. Any help would be greatly appreciated.

Thanks
kmt
kmt is offline   Reply With Quote
Reply

Bookmarks

Tags
forzoominginscrollview, scrollview, view

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 397
16 members and 381 guests
AppsBlogger, chiataytuday, Clouds, David-T, dedeys78, Duncan C, e2applets, EvilElf, heshiming, iekei, leostc, LunarMoon, Murphy, sacha1996, Sami Gh, teebee74
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,127
Posts: 402,912
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:41 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0