简体   繁体   English

单击按钮时取消隐藏UIView

[英]Unhiding a UIView when button is clicked

I've hidden a UIView using 我已经使用隐藏了UIView

_loginview.hidden = YES 

and when I do 当我做的时候

-(IBaction)logInButton:(id)sender {  
_logInView.hidden = NO;  
}  

It still doesn't show when I click the button, can anyone help? 当我单击按钮时它仍然没有显示,有人可以帮忙吗?

I have created a Iboutlet property of UIView and connected it with UIView in storyboard. 我创建了UIView的Iboutlet属性,并将其与情节提要中的UIView连接。 Also ticked hidden. 也打勾隐藏。

Screen shot of hidden view is below(color orange). 隐藏视图的屏幕截图如下(橙色)。 I also sethidden in programmatically way and still working. 我也以编程方式隐藏并且仍在工作。

隐藏的视图

And later on button action I perform setHiden as no and it appeared. 然后在执行按钮操作时,我将setHiden设置为no,它出现了。 Code of IBAction is below:- IBAction的代码如下:-

- (IBAction)loginBtn{

  [hidenView setHidden:NO];
}

You need to setHidden NO on your View when you clocked on uiButton.. 当您在uiButton上计时时,需要在View上设置Hidden NO。

  • (IBaction)logInButton:(id)sender{ [_logInView setHidden:NO]; (IBaction)logInButton:(id)发送器{[_logInView setHidden:NO]; } }

It is working my end by creating this, @property(nonatomic,strong) IBOutlet UIView *viewLogin; 通过创建@Property(nonatomic,strong)IBOutlet UIView * viewLogin;可以达到我的目的。 // in controller.h //在controller.h中

@synthesize viewLogin; @synthesize viewLogin; // in controller.m //在controller.m中

set outlet property for viewlogin in storyboard 在故事板中设置viewlogin的插座属性

and with following IBAction event, 以及以下IBAction事件,

-(IBAction)login:(id)sender{
    [viewLogin setHidden:NO]; }

In storyboard, from connections inspector check that your button is connected properly with a sent event. 在情节提要中,从连接检查器中检查按钮是否与已发送事件正确连接。 Then (if you are performing an async process, maybe login user) try this: 然后(如果您正在执行异步过程,也许是登录用户),请尝试以下操作:

[[NSOperationQueue mainQueue] addOperationWithBlock:^{
    _logInView.hidden = NO;  
}];

witch updates the UI from the main thread. 女巫从主线程更新UI。 Just a guess. 只是一个猜测。

最好使用setAlpha而不是setHidden。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM