Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 多视图应用程序的问题_Objective C_Cocoa_Uiview_Uiscrollview - Fatal编程技术网

Objective c 多视图应用程序的问题

Objective c 多视图应用程序的问题,objective-c,cocoa,uiview,uiscrollview,Objective C,Cocoa,Uiview,Uiscrollview,嗨,我做了一个应用程序,它有两个视图,一个是430像素高的页面滚动视图,另一个是50像素高的静态视图。我的问题有点难以理解,我在静态视图中有info按钮,如果我点击它,程序会因此而崩溃: sharedlibrary apply-load-rules all kill Current language: auto; currently objective-c quit Program ended with exit code: 0 或 但是,如果我在页面滚动视图中使用相同的代码,它就可以完美

嗨,我做了一个应用程序,它有两个视图,一个是430像素高的页面滚动视图,另一个是50像素高的静态视图。我的问题有点难以理解,我在静态视图中有info按钮,如果我点击它,程序会因此而崩溃:

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

但是,如果我在页面滚动视图中使用相同的代码,它就可以完美地工作

我的部分代码:

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...");
}
我不理解它,我希望它会起作用。我只是想理解为什么它不起作用

静态视图是
ViewController
分页滚动视图是
UIScrollView


感谢您的所有回答。

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

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

我没明白你的意思???您使用的选择器是buttonPressed1还是buttonPressed???在页面滚动视图中,我使用buttonPressed1,在静态视图中,我使用buttonPressed1,并且按钮变量的名称是iButton1您是否尝试更改变量名称以及选择器名称???是,在称为buttonPressed1的选择器中,变量名称是iButton1,在哪里选择器名为Button Pressed变量名为iButton必须尝试将addTarget调用更改为:
[iButton addTarget:self action:@selector(Button Pressed:)forControlEvents:UIControlEventTouchUpInside]- (void)buttonPressed:(id)sender { ... }