gpt4 book ai didi

iphone - UIView 内的 UIButton 不可点击

转载 作者:可可西里 更新时间:2023-11-01 04:22:43 25 4
gpt4 key购买 nike

我有点卡在这上面了,我在 UIViewController 中有一个 UIButton,但由于某些原因 UIButton 不是回应。

_downloadButton = [[DownloadButtonViewController alloc] init];
_downloadButton.issue = _issue;
_downloadButton.view.frame = CGRectMake(self.descriptionLabel.frame.origin.x, self.descriptionLabel.frame.origin.y + self.descriptionLabel.frame.size.height + 20, 200, 27);
[self.view addSubview:_downloadButton.view];

UIButton *tmpButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
tmpButton.titleLabel.text = @"test";
tmpButton.frame = CGRectMake(_downloadButton.view.frame.origin.x, _downloadButton.view.frame.origin.y - 30, _downloadButton.view.frame.size.width, _downloadButton.view.frame.size.height);
[self.view addSubview:tmpButton];

为了查看是否没有任何重叠,我添加了另一个 UIButton 稍微低一点,即使我将它添加到相同的位置它仍然有效。

我的应用程序结构是这样的

- UIViewController
- UIScrollView
- ThumbCover
- UIImageView
- DownloadButton --> NOT WORKING
- UIButton --> WORKING
- UILabel
- ThumbCover
- UIImageView
- DownloadButton --> NOT WORKING
- UIButton --> WORKING
- UILabel
- ThumbCover
- UIImageView
- DownloadButton --> NOT WORKING
- UIButton --> WORKING
- UILabel
- ThumbCover
- UIImageView
- DownloadButton --> NOT WORKING
- UIButton --> WORKING
- UILabel

DownloadButton 只是一个简单的UIButton,没什么特别的。

最佳答案

您已将 viewcontroller 的 View 高度指定为 27

_downloadButton.view.frame = CGRectMake(self.descriptionLabel.frame.origin.x, self.descriptionLabel.frame.origin.y + self.descriptionLabel.frame.size.height + 20, 200, 27);

如果您的按钮的框架在其父 View ( View Controller 的 View )框架之外,即上述框架,它不会响应您的触摸

关于iphone - UIView 内的 UIButton 不可点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12470188/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com