【问题标题】:How to Add a UITextView to a UITableView Detail如何将 UITextView 添加到 UITableView 详细信息
【发布时间】:2012-02-06 17:37:02
【问题描述】:

需要一些帮助来弄清楚如何将一些文本(UITextView?)添加到 UITableView 详细视图。屏幕截图显示了一个空白区域,我需要在其中添加 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];
 }

谢谢!

【问题讨论】:

  • 你的意思是当你点击 UITableView Cell 时,你会得到这个页面吗?

标签: ios uitableview uiviewcontroller


【解决方案1】:

创建 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】:

    如果你通过点击Previous TableView得到这个页面, 然后执行以下操作来添加 UITextView:

    1. 转到界面生成器。
    2. 通过将 UITextView 拖到您的视图(当前视图,您已在快照中显示)来放置它。
    3. 将 View 的代理连接到文件的所有者。
    4. 您可以从 IB 添加代码,也可以在运行时在 UITextView 中添加代码。

    希望,它有所帮助。 祝你好运。

    【讨论】:

    • 或者你可以直接把cocoakomali写的代码作为答案。
    • 谢谢,这很有帮助。我最终以编程方式创建了视图。
    • 好。这种方式总是更可取的。因为它使事情变得清晰。
    【解决方案3】:
    UITextView *yourView =[[UITextView alloc] initWithFrame : CGRectMake(15,15,250,300)]autorelease]; // you can alter the frame values.
    
    [detailsViewController.view addsubview : yourView] 
    

    我已经通过输入添加了所有这些代码..我可以确认其正确的语法..使用自动完成。

    【讨论】:

      猜你喜欢
      • 2011-04-02
      • 1970-01-01
      • 1970-01-01
      • 2021-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-28
      相关资源
      最近更新 更多