Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.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
Iphone UIScrollView上UIImageView上的UIButton(不工作)_Iphone_Ios_Uibutton - Fatal编程技术网

Iphone UIScrollView上UIImageView上的UIButton(不工作)

Iphone UIScrollView上UIImageView上的UIButton(不工作),iphone,ios,uibutton,Iphone,Ios,Uibutton,我在UIScrollView上的UIImageView上有ui按钮。但是,按钮不工作(按钮不响应 并写入按钮。userInteractionEnabled=YES)。为什么? 尝试使用以下方法: page1.userInteractionEnabled = NO; btn.userInteractionEnabled = YES; 还要确保您的按钮没有超出ImageView的框架。 还有一件事,为什么不直接将按钮添加到视图而不是图像视图中。尝试使用以下方法: page1.userInterac

我在
UIScrollView
上的
UIImageView
上有
ui按钮。但是,按钮不工作(按钮不响应 并写入
按钮。userInteractionEnabled=YES
)。为什么?

尝试使用以下方法:

page1.userInteractionEnabled = NO;
btn.userInteractionEnabled = YES;
还要确保您的按钮没有超出ImageView的框架。 还有一件事,为什么不直接将按钮添加到视图而不是图像视图中。

尝试使用以下方法:

page1.userInteractionEnabled = NO;
btn.userInteractionEnabled = YES;
还要确保您的按钮没有超出ImageView的框架。 还有一件事,为什么不直接将按钮添加到视图中,而不是图像视图中。

试试这个(测试过的):

试试这个(测试过的):

试试这个

pagingView = [[InfinitePagingView alloc] initWithFrame:CGRectMake(0.f, 0.f,            self.view.frame.size.width, self.view.frame.size.height - naviBarHeight)];
pagingView.delegate = self;
[self.view addSubview:pagingView];

UIImage *image1 = [UIImage imageNamed:[NSString stringWithFormat:@"1.jpg"]];
page1 = [[UIImageView alloc] initWithImage:image1];
page1.frame = CGRectMake(0, 0, pagingView.frame.size.width * 0.8, pagingView.frame.size.height * 0.8);
page1.userInteractionEnabled = YES;
page1.contentMode = UIViewContentModeScaleAspectFit;
[pagingView addPageView:page1];

btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btn.frame = CGRectMake(100, 200, 50, 50);
[btn addTarget:self action:@selector(toControl) forControlEvents:UIControlEventTouchUpInside];
[page1 addSubview:btn];
试试这个

pagingView = [[InfinitePagingView alloc] initWithFrame:CGRectMake(0.f, 0.f,            self.view.frame.size.width, self.view.frame.size.height - naviBarHeight)];
pagingView.delegate = self;
[self.view addSubview:pagingView];

UIImage *image1 = [UIImage imageNamed:[NSString stringWithFormat:@"1.jpg"]];
page1 = [[UIImageView alloc] initWithImage:image1];
page1.frame = CGRectMake(0, 0, pagingView.frame.size.width * 0.8, pagingView.frame.size.height * 0.8);
page1.userInteractionEnabled = YES;
page1.contentMode = UIViewContentModeScaleAspectFit;
[pagingView addPageView:page1];

btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btn.frame = CGRectMake(100, 200, 50, 50);
[btn addTarget:self action:@selector(toControl) forControlEvents:UIControlEventTouchUpInside];
[page1 addSubview:btn];

它以什么方式不起作用?您是否可以发布方法
toControl
的代码?按钮是可见的,但不能按。记录图像视图的帧宽和高度。图像上的按钮大小为320x480。什么是addPageView?它以什么方式不起作用?您可以发布方法
toControl
的代码吗?按钮可见,但不能按。记录图像视图的帧宽和高度。图像上的按钮大小为320x480。什么是addPageView?您可以添加手势识别器我尝试过的代码(pagingView.userInteractionEnabled=YES,page1.userInteractionEnabled=YES,btn.userInteractionEnabled=YES)您可以发送您的示例吗?或者添加手势记录。请告诉我如何发送示例。您可以添加手势识别器我尝试过的代码(pagingView.userInteractionEnabled=YES,page1.userInteractionEnabled=YES,btn.userInteractionEnabled=YES)你能寄你的样品吗?或者加上手势记录。请告诉我如何寄我的样品。