我的标题视图定义如下:(彩色框是各个对象的框架)
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”事件中调用其相应的选择器。
但下一步和上一页 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];
编辑:输入时找到解决方案! 还在分享。答案 0 :(得分:0)
NavigationButtonView 被指定为 LabelsView 的子视图,而不是 myTitleBar 。因此即使它是可见的,用户也无法与它进行交互,因为它正被剪裁。