多视图应用程序的问题

问题描述:

嗨,我做了一个应用程序,它有2个视图是一个分页滚动视图是430像素高度和其他静态视图有50像素。我的问题是有点难以理解,我有信息按钮,在静态视图,如果我点击它的程序瀑布因此:多视图应用程序的问题

sharedlibrary apply-load-rules all kill Current language: auto; currently objective-c quit Program ended with exit code: 0 

2011-03-30 08:51:28.427 PhotoScroller[637:207] -[__NSCFType buttonPressed1]: unrecognized selector sent to instance 0x4b36db0 
2011-03-30 08:51:28.456 PhotoScroller[637:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType buttonPressed1]: unrecognized selector sent to instance 0x4b36db0' 
*** Call stack at first throw: 
(
    0 CoreFoundation      0x00f2f5a9 __exceptionPreprocess + 185 
    1 libobjc.A.dylib      0x01083313 objc_exception_throw + 44 
    2 CoreFoundation      0x00f310bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187 
    3 CoreFoundation      0x00ea0966 ___forwarding___ + 966 
    4 CoreFoundation      0x00ea0522 _CF_forwarding_prep_0 + 50 
    5 UIKit        0x002bc4fd -[UIApplication sendAction:to:from:forEvent:] + 119 
    6 UIKit        0x0034c799 -[UIControl sendAction:to:forEvent:] + 67 
    7 UIKit        0x0034ec2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527 
    8 UIKit        0x0034d7d8 -[UIControl touchesEnded:withEvent:] + 458 
    9 UIKit        0x002e0ded -[UIWindow _sendTouchesForEvent:] + 567 
    10 UIKit        0x002c1c37 -[UIApplication sendEvent:] + 447 
    11 UIKit        0x002c6f2e _UIApplicationHandleEvent + 7576 
    12 GraphicsServices     0x01887992 PurpleEventCallback + 1550 
    13 CoreFoundation      0x00f10944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52 
    14 CoreFoundation      0x00e70cf7 __CFRunLoopDoSource1 + 215 
    15 CoreFoundation      0x00e6df83 __CFRunLoopRun + 979 
    16 CoreFoundation      0x00e6d840 CFRunLoopRunSpecific + 208 
    17 CoreFoundation      0x00e6d761 CFRunLoopRunInMode + 97 
    18 GraphicsServices     0x018861c4 GSEventRunModal + 217 
    19 GraphicsServices     0x01886289 GSEventRun + 115 
    20 UIKit        0x002cac93 UIApplicationMain + 1160 
    21 PhotoScroller      0x00001c20 main + 102 
    22 PhotoScroller      0x00001bb1 start + 53 
    23 ???         0x00000001 0x0 + 1 
) 
terminate called after throwing an instance of 'NSException' 

但如果我使用分页滚动视图相同的代码,它完美的我的代码

部分:

UIButton *iButton = [UIButton buttonWithType:UIButtonTypeInfoLight]; 
iButton.frame = CGRectMake(269.0f, 17.0f, 18.0f, 19.0f); 
iButton.backgroundColor = [UIColor clearColor]; 
[iButton addTarget:self action:@selector(buttonPressed) 
forControlEvents:UIControlEventTouchUpInside];  
[self.view addSubview:iButton]; 

-(void)buttonPressed{ 
    NSLog(@"button pressed in PSV..."); 
} 

I D不理解它,我期望它能起作用。我只是想明白为什么它不起作用。

静态视图是ViewController 页面滚动视图子类是UIScrollView <UIScrollViewDelegate>

感谢所有的答案的子类。

+0

我没有给你?你正在使用buttonPressed1或buttonPressed的选择器是什么?分页滚动视图中的 – makboney 2011-03-30 07:38:14

+0

我在静态视图中使用buttonPressed我使用buttonPressed1,并且按钮变量的名称是iButton1 – Csabi 2011-03-30 07:49:01

+0

您是否尝试通过更改变量名称以及选择器名称? – makboney 2011-03-30 07:56:09

您为某个按钮的动作指定的选择器应该带有一个类型为id的单个参数。因此,请尝试将您的选择器规格更改为@selector(buttonPressed:),并将您的操作方法更改为:

- (void)buttonPressed:(id)sender { ... } 
+0

我不知道我100%理解你的答案,但我投票了 – Csabi 2011-03-30 18:21:08

+0

只是尝试改变你的addTarget调用: '[iButton addTarget:self action:@selector(buttonPressed :) forControlEvents:UIControlEventTouchUpInside];'然后将一个参数传递给您的buttonPressed方法,如上所示。希望这会有所帮助! – Laura 2011-03-31 15:26:15