2012-02-06 108 views
0

需要一些幫助來弄清楚如何將一些文本(UITextView?)添加到UITableView細節視圖。屏幕截圖顯示了我需要添加UITextView的空白空間。如何將UITextView添加到UITableView細節

這裏是什麼,我有一個截圖:

UITableView that needs a UITextView

這裏就是我分配的UITableView細節稱號值的方法。

//MainViewControler.m 
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UIViewController *detailsViewController = [[UIViewController alloc] init]; 


    // get detail view controller "title" value 
    detailsViewController.title = word.term; 



    [[self navigationController] pushViewController:detailsViewController animated:YES]; 
    [detailsViewController release]; 
} 

謝謝!

+0

你的意思是當你點擊UITableView Cell時,你會得到這個頁面的權利? – Krishna 2012-02-06 17:40:11

+0

對,你是:-) – Slinky 2012-02-06 17:54:56

回答

2

創建detailsViewController對象後,添加以下代碼:

UITextView *txtView = [[UITextView alloc] init]; 
txtView.text = @"UITextView text"; 
txtView.frame = CGRectMake(0,0,320,100); 
[detailsViewController.view addSubview:txtView]; 
[txtView release]; 
txtView = nil; 
2

如果通過單擊上一頁TableView中得到這個頁面, 然後做了添加UITextView中的以下內容:

  1. 轉到Interface Builder。
  2. 將UITextView拖到您的視圖(當前視圖,您在快照中顯示)。
  3. 將視圖的委託連接到文件的所有者。
  4. 您可以從IB或運行時在UITextView中添加代碼。

希望它有幫助。 祝你好運。

+0

或者你可以把可可立體寫的代碼作爲答案,直截了當。 – Krishna 2012-02-06 17:47:05

+0

謝謝,這很有幫助。我最終以編程方式創建了視圖。 – Slinky 2012-02-06 17:56:49

+0

好。這種方式總是可取的。事情很清楚。 – Krishna 2012-02-06 17:59:20

1
UITextView *yourView =[[UITextView alloc] initWithFrame : CGRectMake(15,15,250,300)]autorelease]; // you can alter the frame values. 

[detailsViewController.view addsubview : yourView] 

我已經添加了所有這些代碼從打字..我可以確認其正確的語法..使用自動完成。

+0

非常感謝! – Slinky 2012-02-06 17:57:37