简体   繁体   中英

Unhiding a UIView when button is clicked

I've hidden a UIView using

_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. 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. Code of IBAction is below:-

- (IBAction)loginBtn{

  [hidenView setHidden:NO];
}

You need to setHidden NO on your View when you clocked on uiButton..

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

It is working my end by creating this, @property(nonatomic,strong) IBOutlet UIView *viewLogin; // in controller.h

@synthesize viewLogin; // in controller.m

set outlet property for viewlogin in storyboard

and with following IBAction event,

-(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. Just a guess.

最好使用setAlpha而不是setHidden。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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