2012-02-06 113 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