Iphone 带xib-won和x27的模态uiviewcontroller;不显示隐藏的控件
我有一个带有xib的简单UIViewcontroller。我以模态的方式展示了它,它正确地显示了我在xib上有三个控件,我想隐藏它们,直到用户按下OK按钮,然后在应用程序连接到远程服务器时显示,然后在连接完成时隐藏它们自己。我已将它们正确地连接到IBO插座上。我的问题是,当调用OK按钮所连接的iAction方法时,将它们的hidden属性设置为NO不会使它们可见。代码如下:Iphone 带xib-won和x27的模态uiviewcontroller;不显示隐藏的控件,iphone,ios,cocoa-touch,Iphone,Ios,Cocoa Touch,我有一个带有xib的简单UIViewcontroller。我以模态的方式展示了它,它正确地显示了我在xib上有三个控件,我想隐藏它们,直到用户按下OK按钮,然后在应用程序连接到远程服务器时显示,然后在连接完成时隐藏它们自己。我已将它们正确地连接到IBO插座上。我的问题是,当调用OK按钮所连接的iAction方法时,将它们的hidden属性设置为NO不会使它们可见。代码如下: #import <UIKit/UIKit.h> #import "PasswordWebViewControl
#import <UIKit/UIKit.h>
#import "PasswordWebViewController.h"
@interface ExistingUserController : UIViewController<UITextFieldDelegate> {
UITextField *emailField;
UITextField *passwordField;
NSString *password;
NSString *email;
UIActivityIndicatorView *spinner;
UIImageView *loadingImg;
UILabel *loadingLabel;
}
@property (nonatomic, retain) IBOutlet UITextField *emailField;
@property (nonatomic, retain) IBOutlet UITextField *passwordField;
@property (nonatomic, retain) NSString *email;
@property (nonatomic, retain) NSString *password;
@property (nonatomic, retain) IBOutlet UIActivityIndicatorView *spinner;
@property (nonatomic, retain) IBOutlet UILabel *loadingLabel;
@property (nonatomic, retain) IBOutlet UIImageView *loadingImg;
-(IBAction) onClickSend: (id) sender;
-(IBAction) onClickCancel: (id) sender;
-(IBAction) onClickResetPW: (id) sender;
-(void)showLoadingIndicators;
-(void)hideLoadingIndicators;
@end
这很好,但是当我在onClickSend方法中调用showLoadingIndicators,将hidden设置为NO时,控件就不会显示。它肯定叫这个方法
-(IBAction) onClickSend: (id) sender{
if ([email length] >0 && [password length] >0){
UIApplication *myApp = [UIApplication sharedApplication];
[self showLoadingIndicators];
noIBAppDelegate*appDelegate = (noIBAppDelegate*)myApp.delegate;
[appDelegate tryLoadingUserEmail:email AndPassword:password];
}
else{
UIAlertView *missingAlert = [[[UIAlertView alloc] initWithTitle:@"Error" message:@"You have a blank email or password." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease];
[missingAlert show];
}
}
-(void)showLoadingIndicators{
self.loadingImg.hidden =NO;
[self.view bringSubviewToFront:loadingImg];
self.loadingLabel.hidden = NO;
[self.view bringSubviewToFront:loadingLabel];
[self.spinner startAnimating];
}
我可能错过了一些明显的东西 请注意,设置可见性的另一种方法是将标签(和其他屏幕项目)的alpha设置为1(可见)或0(不可见)。这可能行得通 e、 g
你合成标签了吗?如果没有,我认为您应该使用[loadingLabel setHidden:YES] 您如何知道
hideLoadingIndicators
正在工作?您确定默认情况下这些控件没有隐藏吗?我已经检查了xib中控件的隐藏属性,如果我没有调用hideLoadingIndicators方法,那么它们是可见的。您如何设置电子邮件
和密码
?您提到正在调用该方法。你指的是showLoadingIndicators
还是onClickSend:
?事实上,我自己在自己的应用程序中使用了alpha,因为“隐藏”对我不起作用。
-(IBAction) onClickSend: (id) sender{
if ([email length] >0 && [password length] >0){
UIApplication *myApp = [UIApplication sharedApplication];
[self showLoadingIndicators];
noIBAppDelegate*appDelegate = (noIBAppDelegate*)myApp.delegate;
[appDelegate tryLoadingUserEmail:email AndPassword:password];
}
else{
UIAlertView *missingAlert = [[[UIAlertView alloc] initWithTitle:@"Error" message:@"You have a blank email or password." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease];
[missingAlert show];
}
}
-(void)showLoadingIndicators{
self.loadingImg.hidden =NO;
[self.view bringSubviewToFront:loadingImg];
self.loadingLabel.hidden = NO;
[self.view bringSubviewToFront:loadingLabel];
[self.spinner startAnimating];
}
self.loadingLabel.alpha = 0;