ios - 信息按钮未链接到其他 View Controller

标签 ios cocoa-touch uibutton segue

我有一个信息按钮,它显示为相机 View 顶部的覆盖 UIView,但未链接到所需的 View Controller 。触摸时什么也不会发生。

这是创建按钮并链接它的代码

    // Create a Button to get Help
    infoButton =  [UIButton buttonWithType:UIButtonTypeInfoLight ] ;
    CGRect buttonRect = infoButton.frame;

    // Calculate the bottom right corner
    buttonRect.origin.x = 455;
    buttonRect.origin.y = 297;
    [infoButton setFrame:buttonRect];

    [infoButton addTarget:self action:@selector(presentInfo) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:infoButton];

这是创建segue的代码

- (void) presentInfo
{
InfoViewController *ivc = [self.storyboard instantiateViewControllerWithIdentifier:@"InfoViewController"];
[self presentModalViewController:ivc animated:YES];
}

最佳答案

首先尝试一下: - 设置断点:

- (void) presentInfo
{
InfoViewController *ivc = [self.storyboard instantiateViewControllerWithIdentifier:@"InfoViewController"];
[self presentModalViewController:ivc animated:YES];
}

如果程序达到这个程度,那么一定是转场出现了问题。

本周我也遇到了一些按钮问题。就我而言,我的按钮上曾经有另一个 UIView,所以它不会点击选择器。 或者您可以尝试更改:

[infoButton addTarget:self action:@selector(presentInfo) forControlEvents:UIControlEventTouchUpInside];

在:

[infoButton addTarget:self action:@selector(presentInfo) forControlEvents:UIControlEventTouchDown];

还要查看按钮是否对您的触摸使用react并使用替代图像。

希望这有帮助

哦,或者尝试给它一个你制作的 UITapGestureRecognizer,但这只是为了真正绝望的解决方案,如果没有其他办法......

关于ios - 信息按钮未链接到其他 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12266139/

相关文章:

ios - 如何将 UIView 链接到 UICollectionViewCell?

iphone - 如何在触摸和按住期间动态更改 UIButton 标题

ios - 在 iOS 中以编程方式生成 OpenGL 顶点数据

ios - 如何关闭单个React Native模拟器?

cocoa-touch - UIView -- "user interaction enabled"在父级上为假但在子级上为真?

ios - 以编程方式切换选项卡无法正常工作

ios - 格式化整数值

c++ - Three.js 移植到原生代码?

ios - 带有 IB_DESIGNABLE 的 UIButton 会引发运行时属性警告,并且不会在 Interface Builder 中呈现

ios - 设置在 uitableview 单元格中添加的 uilabel 文本