捏手势识别器

时间:2012-01-27 14:23:51

标签: iphone objective-c xcode4

合适的人,我刚刚开始进入Xcode 4,打算开始制作iPhone应用程序。没什么太重要的,不是游戏等...但是我正在努力应对这种捏合的姿态....

出于某种原因,当我使用iphone 5.0模拟器时它一切正常......但是当我在iphone 3G上导出并尝试它时,我在使用夹点设备加载屏幕时会出现错误。

我正在使用此代码进行捏合手势:

<。>文件中的

-(IBAction)Zoom:(UIPinchGestureRecognizer *)recognizer;
<。>文件中的

-(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...

1 个答案:

答案 0 :(得分:10)

尝试以编程方式添加UIPinchGestureRecognizer。如果您已从IB

添加了UIPinchGestureRecognizer,则会发生这种情况
UIPinchGestureRecognizer *pinch =[[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlerMethiod:)];
    [pinch setDelegate:self];
    [self.view addGestureRecognizer:pinch];

请看这个链接: