【问题标题】:next/prev UIButtons not responding下一个/上一个 UIButtons 没有响应
【发布时间】:2013-06-20 06:34:53
【问题描述】:

我有一个如下定义的标题视图:(彩色框是各个对象的框架)

LeftMost Red Box            : UIButton   : BackButton
White Box                   : UIView     : LabelsView, Contains Label 1 & Label 2
Green Box + Text            : UILabel    : Label 1
Red Box   + Text            : UILabel    : Label 2
Second White Box            : UIView     : NavigationButtonView, Contains Next And Previous Button
Two Rightmost Green Boxes   : UIButtons  : Next and Previous Button

以上都进入

UIView * myTitleBar;

BackButton 正在工作,并且正在“Touch Up Inside”事件中调用其各自的选择器。

但是 NextPrevious UIButtons 定义如下:

    UIButton *prevImageButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 10, navButtonWidth, navButtonHeight)];
    [prevImageButton addTarget:self action:@selector(prevImageButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [prevImageButton setBackgroundColor:[UIColor greenColor]];

    UIButton *nextImageButton = [[UIButton alloc]initWithFrame:CGRectMake(navButtonWidth + navButtonWidth, 10, navButtonWidth, navButtonHeight)];
    [nextImageButton addTarget:self action:@selector(nextImageButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [nextImageButton setBackgroundColor:[UIColor greenColor]];

不要回应。

nextImageButtonPressed 定义如下:

- (IBAction)nextImageButtonPressed:(id)sender{
    NSLog(@"Function Called");
    .
    .
    .
}

什么可能导致这个问题? 我尝试使用添加按钮 [titleBarLabelView insertSubview:navigationButtonView atIndex:1000];

编辑:在键入此内容时找到了解决方案! 仍在分享。

【问题讨论】:

    标签: ios cocoa-touch ios6 uiview uibutton


    【解决方案1】:

    NavigationButtonView 被指定为 LabelsView 的子视图,而不是 myTitleBar。因此,即使它是可见的,用户也无法与之交互,因为它正在被剪裁。

    【讨论】:

      猜你喜欢
      • 2015-06-23
      • 2010-11-10
      • 1970-01-01
      • 1970-01-01
      • 2021-11-14
      • 1970-01-01
      • 2013-12-21
      • 2013-09-25
      • 1970-01-01
      相关资源
      最近更新 更多