2012-01-27 144 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