我有一个标题视图定义如下:(彩色框是各个对象的框架)
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] 添加按钮;
编辑:在键入此内容时找到了解决方案!还在分享。