2013-06-20 54 views
0

我有一個標題瀏覽定義如下:(在彩色盒是用於各個對象幀)下一/先前UIButtons沒有響應

enter image description here上述

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

NavigationButtonView正在指定爲LabelsView代替myTitleBar的子視圖。所以即使它是可見的,用戶也不能與它進行交互,因爲它正在被剪輯。