2012-01-27 115 views
2

正确的家伙,我刚开始进入Xcode 4,打算开始制作iPhone应用程序。没有太大的主题,不是游戏等......但我正在努力与这种捏手势....捏捏手势识别器

由于某种原因,当我使用iphone 5.0模拟器时,一切正常......但是,当涉及到出口和尝试它在我的iPhone 3G上,当我用捏设施加载屏幕时出现错误。

我使用此代码为捏合手势:

在.h文件

-(IBAction)Zoom:(UIPinchGestureRecognizer *)recognizer; 

在.m文件:

-(IBAction)Zoom:(UIPinchGestureRecognizer *)recognizer{ 
    recognizer.view.transform = CGAffineTransformScale(recognizer.view.transform, recognizer.scale,recognizer.scale); recognizer.scale = 1; 
} 

但是当我点击我的按钮使用此代码加载具有手势功能(OurWorkSubOne)的屏幕:

-(IBAction)switchViewSeven:(id)sender { 
    OurWorkSubOne *second = [[OurWorkSubOne alloc] initWithNibName:nil bundle:nil]; 
    [self presentModalViewController:second animated:YES]; 
} 

我得到这样的输出:

GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Fri Sep 16 06:56:50 UTC 2011) 
Copyright 2004 Free Software Foundation, Inc. 
GDB is free software, covered by the GNU General Public License, and you are 
welcome to change it and/or distribute copies of it under certain conditions. 
Type "show copying" to see the conditions. 
There is absolutely no warranty for GDB. Type "show warranty" for details. 
This GDB was configured as "--host=i386-apple-darwin --target=arm-apple-darwin".tty /dev/ttys001 
target remote-mobile /tmp/.XcodeGDBRemote-1916-56 
Switching to remote-macosx protocol 
mem 0x1000 0x3fffffff cache 
mem 0x40000000 0xffffffff none 
mem 0x00000000 0x0fff none 
[Switching to process 11523 thread 0x2d03] 
[Switching to process 11523 thread 0x2d03] 
sharedlibrary apply-load-rules all 
warning: Unable to read symbols for /Users/mediastation/Library/Developer/Xcode/iOS DeviceSupport/4.2.1 (8C148)/Symbols/usr/lib/info/dns.so (file not found). 
warning: No copy of dns.so found locally, reading from memory on remote device. This may slow down the debug session. 
2012-01-27 14:14:31.116 Mediastation[1261:307] -[UIPinchGestureRecognizer initWithCoder:]: unrecognized selector sent to instance 0x176bb0 
2012-01-27 14:14:31.238 Mediastation[1261:307] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIPinchGestureRecognizer initWithCoder:]: unrecognized selector sent to instance 0x176bb0' 
*** Call stack at first throw: 
(
    0 CoreFoundation      0x3759dc7b __exceptionPreprocess + 114 
    1 libobjc.A.dylib      0x32d9bee8 objc_exception_throw + 40 
    2 CoreFoundation      0x3759f3e3 -[NSObject(NSObject) doesNotRecognizeSelector:] + 98 
    3 CoreFoundation      0x37544467 ___forwarding___ + 506 
    4 CoreFoundation      0x37544220 _CF_forwarding_prep_0 + 48 
    5 UIKit        0x35bf3bbc UINibDecoderDecodeObjectForValue + 2384 
    6 UIKit        0x35bf3d5c -[UINibDecoder decodeObjectForKey:] + 108 
    7 UIKit        0x35b643d8 -[UIRuntimeConnection initWithCoder:] + 120 
    8 UIKit        0x35b649b0 -[UIRuntimeEventConnection initWithCoder:] + 48 
    9 UIKit        0x35bf3bbc UINibDecoderDecodeObjectForValue + 2384 
    10 UIKit        0x35bf3578 UINibDecoderDecodeObjectForValue + 780 
    11 UIKit        0x35bf3d5c -[UINibDecoder decodeObjectForKey:] + 108 
    12 UIKit        0x35b636d0 -[UINib instantiateWithOwner:options:] + 660 
    13 UIKit        0x35b65640 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 140 
    14 UIKit        0x35a7e3ac -[UIViewController _loadViewFromNibNamed:bundle:] + 56 
    15 UIKit        0x35a7d280 -[UIViewController loadView] + 128 
    16 UIKit        0x35926df4 -[UIViewController view] + 52 
    17 UIKit        0x35935550 -[UIViewController viewControllerForRotation] + 56 
    18 UIKit        0x35935480 -[UIViewController _visibleView] + 112 
    19 UIKit        0x35935408 -[UIViewController rotatingContentViewForWindow:] + 20 
    20 UIKit        0x359eab78 -[UIClientRotationContext initWithClient:toOrientation:duration:andWindow:] + 364 
    21 UIKit        0x35a40664 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 928 
    22 UIKit        0x359e9548 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:] + 880 
    23 UIKit        0x359e8c98 -[UIViewController presentModalViewController:withTransition:] + 2792 
    24 UIKit        0x359e8060 -[UIViewController presentModalViewController:animated:] + 96 
    25 Mediastation      0x00002f13 -[OurWork switchViewSeven:] + 82 
    26 CoreFoundation      0x37542a43 -[NSObject(NSObject) performSelector:withObject:withObject:] + 26 
    27 UIKit        0x35902f20 -[UIApplication sendAction:to:from:forEvent:] + 136 
    28 UIKit        0x35902e88 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 40 
    29 UIKit        0x35902e50 -[UIControl sendAction:to:forEvent:] + 52 
    30 UIKit        0x35902aa0 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 536 
    31 UIKit        0x359025c4 -[UIControl touchesBegan:withEvent:] + 268 
    32 UIKit        0x358f4e38 -[UIWindow _sendTouchesForEvent:] + 468 
    33 UIKit        0x358f44e4 -[UIWindow sendEvent:] + 396 
    34 UIKit        0x358d7c9c -[UIApplication sendEvent:] + 452 
    35 UIKit        0x358d73b4 _UIApplicationHandleEvent + 6824 
    36 GraphicsServices     0x33e77c88 PurpleEventCallback + 1048 
    37 CoreFoundation      0x3752f5cb __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 28 
    38 CoreFoundation      0x3752f589 __CFRunLoopDoSource1 + 164 
    39 CoreFoundation      0x37521835 __CFRunLoopRun + 580 
    40 CoreFoundation      0x3752150b CFRunLoopRunSpecific + 226 
    41 CoreFoundation      0x37521419 CFRunLoopRunInMode + 60 
    42 GraphicsServices     0x33e76d24 GSEventRunModal + 196 
    43 UIKit        0x3591d57c -[UIApplication _run] + 588 
    44 UIKit        0x3591a558 UIApplicationMain + 972 
    45 Mediastation      0x000020c3 main + 106 
    46 Mediastation      0x00002054 start + 40 
) 
terminate called after throwing an instance of 'NSException' 
kill 
Current language: auto; currently objective-c 
quit 
Program ended with exit code: 0 


ANY IDEAS GUYS??? I WOULD APPRECIATE ANY HELP... 
+0

你在哪里添加你的手势识别?你是通过Interface Builder来做的吗? – 2012-01-27 14:29:10

+0

您的iPhone 3G运行iOS版本是什么? – amattn 2012-01-27 14:30:52

+0

是的,我通过界面生成器添加它,刚删除它,并重新加载到我的iPhone上的应用程序,我没有得到任何错误和页面正在显示? – WLyne86 2012-01-27 14:32:03

回答

10

尝试增加UIPinchGestureRecognizer编程。这可能发生,如果你已经从IB

UIPinchGestureRecognizer *pinch =[[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlerMethiod:)]; 
    [pinch setDelegate:self]; 
    [self.view addGestureRecognizer:pinch]; 

加入UIPinchGestureRecognizer看到这个链接:

+0

欢呼生病给了一个去垫子 – WLyne86 2012-01-27 14:43:37

+0

完美的是,可可性是一个很大的帮助:D – WLyne86 2012-01-27 15:00:03

+0

多德请投票答案 – Krrish 2012-01-30 12:29:46