【问题标题】:Info button not linking to other view controller信息按钮未链接到其他视图控制器
【发布时间】:2012-09-04 14:54:54
【问题描述】:

我有一个信息按钮,它显示为未链接到所需视图控制器的相机视图顶部的覆盖 UIView。当它被触摸时没有任何反应。

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

    // 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];
}

【问题讨论】:

  • 尝试关闭相机,并在相机关闭完成处理程序中调用视图更改。

标签: ios cocoa-touch uibutton segue


【解决方案1】:

先试试这个: - 在以下位置设置断点:

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

如果程序达到这一点,那肯定是segue有问题。

这周我的按钮也有一些问题。在我的情况下,我的按钮上曾经有另一个 UIView,所以它不会点击选择器。 或者你可以尝试改变:

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

在:

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

同时查看按钮是否对您的触摸做出反应并显示替代图像。

希望对你有帮助

哦,或者尝试给它一个您制作的 UITapGestureRecognizer,但这仅适用于真正绝望的解决方案,如果没有其他方法...

【讨论】:

  • 感谢您的提示!我的选择器有问题。断点解决方案很有帮助
猜你喜欢
  • 2015-08-03
  • 1970-01-01
  • 2013-05-01
  • 2013-07-11
  • 2014-11-14
  • 1970-01-01
  • 2012-10-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多