如何设置TextView以显示单击按钮

时间:2010-06-17 11:57:14

标签: iphone

我有一个UITextView对象,我在界面生成器中创建了它的隐藏属性unmarked.Now我希望这个textView在我的应用程序启动和第一个视图出现时不可见。我还希望它在特定方法时显示call.Now这是我在视图中写的加载

[mTextView setHidden:YES];

self.mTextView=[[UITextView alloc] init];

它隐藏了textView ats第一个视图出现,但是当我调用了我想要的方法并且我写了

[mTextView setHidden:NO]; 它没有再显示.. 是否因为在分配了内存为

之后我们无法更改textView的外观

self.mTextView = [[UITextView alloc] init]; 然后写

[mTextView setHidden:YES];

它不会隐藏viwDidLoad中的textView .....

1 个答案:

答案 0 :(得分:1)

您需要在主视图中添加

即。

[self.view addSubView:mTextView];

(初始化后)

并交换这两行

[mTextView setHidden:YES];

self.mTextView=[[UITextView alloc] init];

所以你的代码将是

 self.mTextView=[[UITextView alloc] init];
[mTextView setHidden:YES];
[self.view addSubView:mTextView];
相关问题