2012-03-24 108 views
0

我有一個導航欄有一個自定義按鈕,該按鈕的點擊事件有一個自定義彈出菜單,有一個表,當我點擊錶行didselectrowatindexpath方法沒有調用。導航欄事件問題

我使用此代碼,請解決此

這裏

-(void)backButtonClicked1 



{ 


   // create and configure the view 
   CGRect cgRct = CGRectMake(220, 30, 93, 135); //define size and position of view 
    
   myView = [[UIView alloc] initWithFrame:cgRct]; 

   myView.backgroundColor=[UIColor clearColor]; 

   [myView setUserInteractionEnabled:YES]; 
    
     UIButton *btnpop=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 93, 140)]; 
    
    [btnpop setUserInteractionEnabled:YES]; 

   [btnpop setImage:[UIImage imageNamed:@"[email protected]"] forState:UIControlStateNormal]; 

   [myView addSubview:btnpop]; 
    
   //[self.navigationController.navigationBar bringSubviewToFront:myView]; 

 // [myView release]; 
    
  
   table = [[UITableView alloc]initWithFrame:CGRectMake(1,20,90,114) 

style:UITableViewStylePlain]; 

   [table setUserInteractionEnabled:YES]; 

   table.backgroundColor = [UIColor clearColor]; 

   table.separatorColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"[email protected]"]]; 

   table.scrollEnabled=NO; 

   table.layer.borderColor = [UIColor clearColor].CGColor; 

   table.layer.borderWidth=1.0; 

   table.layer.cornerRadius = 4; 

   [table setDataSource:self]; 

   [table setDelegate:self]; 

    
   [myView addSubview:table]; 

   myView.autoresizesSubviews = YES;   
   //allow it to tweak size of elements in view 
    
   [self.navigationController.navigationBar addSubview:myView]; 

   [self.navigationController.navigationBar bringSubviewToFront:table]; 

    
 } 
+0

我沒有看到任何didSelectRowAtIndexPath方法在你提供的代碼,關心上傳呢? – 2012-03-24 09:21:44

回答

2

輸入驗證碼,您應該對相應的.m類中添加這

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    // Do your code here... 

} 

方法。

1

正如你所寫的代表=自我& datasource = self那麼你應該寫你的委託&數據源方法內自我類。

請執行

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    // Do your code here... 

}