Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c iphone sdk在UI上隐藏uitextview按钮单击_Objective C - Fatal编程技术网

Objective c iphone sdk在UI上隐藏uitextview按钮单击

Objective c iphone sdk在UI上隐藏uitextview按钮单击,objective-c,Objective C,我对iphonesdk编程还不熟悉,并且已经被困在这个问题上好几天了 我想要一个切换uitextview的按钮。第一次单击显示文本框,第二次单击隐藏文本框,依此类推 听起来很简单创建UIButton的实例,并将其目标设置为将切换UITextView实例的隐藏属性的方法。例如,假设您有一个名为discosearingtextview的UITextView实例变量 - (void)loadView { [super loadView]; // Add the UITextView.

我对iphonesdk编程还不熟悉,并且已经被困在这个问题上好几天了

我想要一个切换uitextview的按钮。第一次单击显示文本框,第二次单击隐藏文本框,依此类推


听起来很简单

创建UIButton的实例,并将其目标设置为将切换UITextView实例的隐藏属性的方法。例如,假设您有一个名为discosearingtextview的UITextView实例变量

- (void)loadView
{
    [super loadView];

    // Add the UITextView.
    disappearingTextView = [[UITextView alloc] initWithFrame:CGRectMake(10, 10, 300, 200)];
    [[self view] addSubview:disappearingTextView];

    // Add the button, and add self as target, with toggleTextViewHidden as the action to trigger on TouchUpInside.
    UIButton *toggleTextViewHiddenButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [toggleTextViewHiddenButton setFrame:CGRectMake(10, 220, 300, 44)];
    [toggleTextViewHiddenButton addTarget:self action:@selector(toggleTextViewHidden) forControlEvents:UIControlEventTouchUpInside];
    [[self view] addSubview:toggleTextViewHiddenButton];
}
然后,在toggleTextViewHidden方法中,切换消失文本视图的隐藏属性

- (void)toggleTextViewHidden
{
    [disappearingTextView setHidden:( ! [disappearingTextView isHidden])];
}