2011-12-02 72 views
-1

我創建了一個應用程序,其中如果我選擇表視圖中的特定行比選定的行將展開(我已經實現行onclick行完全擴展,但我有問題[cell.contentview addsubview:]請參閱圖像我有提供)&有一些按鈕,但我不能在表視圖中獲得完美的視圖沒有點擊行我可以看到其他單元格的按鈕here is image!如何添加按鈕cell.contentview不工作完美?

我的代碼顯示按鈕在這裏。

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 


     static NSString *CellIdentifier = @"Cell"; 

     cell = [tableBusiness dequeueReusableCellWithIdentifier:CellIdentifier]; 
     if (cell == nil) { 

      //cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease]; 
      cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; 
     } 
     //cell.textLabel.borderStyle = UITextBorderStyleNone; 
     cell.textLabel.text = [NSString stringWithFormat:@"%d",indexPath.row]; 

     UILabel *theText = [[UILabel alloc] initWithFrame:CGRectMake(10.0,10.0, 200, 22.0)]; 
     theText.text = [NSString stringWithFormat:@" Title Text %d",indexPath.row]; 
     [cell.contentView addSubview:theText]; 

     btnMenu = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
     btnMenu.frame = CGRectMake(80, 160, 100, 37); 
     [btnMenu setTitle:@"Go to Menu" forState:UIControlStateNormal]; 
     [btnMenu addTarget:nil action:@selector(accessoryTypeForRowWithIndexPath:) forControlEvents:UIControlEventTouchUpInside]; 
     [cell.contentView addSubview:btnMenu]; 
     //textView.text = nil;  

     return cell; 
     [btnMenu release]; 

     [theText release]; 

} 

&我要讓按鈕事件像點擊特定按鈕打開,當點擊按鈕的產品怎麼辦? 沒有任何解決方案,請幫助我。 i want to create like this !Here is description for the image thread.

here its link for how to expand row.?

+0

這真的很噁心......如果有人不能給出答案,那麼請告訴我爲什麼你投了我的問題。你已經完美地閱讀了我的問題。有沒有人看到我提供的所有有用的數據來解釋你?任何人都可以告訴我這裏怎麼了? –

回答

0

如果你想增加細胞的高度,然後ü可以用下面的代碼

UITableView *movieListTbl; 
movieListTbl.rowHeight = "Height of cell"; 

嘗試,但要記住,你委託你的tableview。

+0

我想你沒有明白我的觀點。請閱讀我的問題,我已經實現了行增加,但我想知道我的答案cell.content查看請參閱我提供的圖像。這裏這個標籤是圖片! –