2012-03-24 110 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... 

}