로그인보기와 웹보기의 두 가지보기가있는 하나의 iPhone 응용 프로그램을 만들고 있습니다. 사용자가 로그인 자격 증명을 입력하면 웹보기로 리디렉션됩니다. 로그인보기에서 웹보기를로드하는 데 너무 많은 시간이 걸립니다. 그래서 나는 이미지를로드하는 것을 보여주는 alertview를 사용했다.이미지 애니메이션로드를 중지 한 후 웹보기 내용을 읽을 수 없습니다.
@interface FocusViewController()
@end
@implementation FocusViewController
@synthesize txtsecurecode;
@synthesize webView;
@synthesize OrganizationCode;
UIActivityIndicatorView *indicator;
UIAlertView *alert;
- (void)viewDidLoad
{
[super viewDidLoad];
appDelegate = (FocusAppDelegate *)[[UIApplication sharedApplication]delegate];
if(appDelegate.data.strOrganizationCode == nil || appDelegate.data.strAccessCode == nil)
{
NSLog(@"YOUR FIRST SCREEN");
_loginView.hidden = NO;
webView.hidden = YES;
}
else
{
NSLog(@"LOAD WEBVIEW DIRECTLY\n");
NSLog(@"Organization Code -> %@ \n Secure Access Code -> %@",appDelegate.data.strOrganizationCode,appDelegate.data.strAccessCode);
OrganizationCode.text = appDelegate.data.strOrganizationCode ;
txtsecurecode.text = appDelegate.data.strAccessCode;
[self loginClicked:nil];
webView.hidden = NO;
_loginView.hidden = YES;
}
}
- (IBAction)loginClicked:(id)sender {
@try {
if([[txtsecurecode text] isEqualToString:@""] || [[OrganizationCode text] isEqualToString:@""]) {
[self alertStatus:@"Please enter Access code" :@"Login Failed!":0];
}
else
{
NSString *post =[[NSString alloc] initWithFormat:@"txtsecurecode=%@ @&password=%@",[txtsecurecode text],[OrganizationCode text]];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://myexample.com/AccountService/security/ValidateAccess?accesscode=%@&companycode=%@&type=1", txtsecurecode.text, OrganizationCode.text]];
NSString *responseData = [[NSString alloc]initWithData:[NSData dataWithContentsOfURL:url] encoding:NSUTF8StringEncoding];
if([responseData isEqualToString:@""]){
[self alertStatus:@"Please enter valid Access Code" :@"Login Failed !" :0];
}
else
{
appDelegate.data.strOrganizationCode = OrganizationCode.text;
appDelegate.data.strAccessCode = txtsecurecode.text;
[FocusAppDelegate addCustomObjectToUserDefaults:appDelegate.data key:kCredentails];
//Updated
_loginView.hidden = YES;
webView.hidden = NO;
responseData = [responseData stringByReplacingOccurrencesOfString:@" "" " withString:@""];
NSString* encodedString = [responseData stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"Response ==> %@" ,encodedString);
alert = [[[UIAlertView alloc] initWithTitle:@"Loading\nPlease Wait..." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil] autorelease];
[alert show];
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
indicator.center = CGPointMake(alert.bounds.size.width/2, alert.bounds.size.height - 50);
[indicator startAnimating];
[alert addSubview:indicator];
[indicator release];
webView.backgroundColor = [UIColor clearColor];
webView.opaque = NO;
webView.delegate = self;
webView.frame = self.view.bounds;
NSString* urlTwo = [[encodedString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
stringByReplacingOccurrencesOfString:@"%22" withString:@""];
NSURL *url2;
if([urlTwo hasPrefix:@"http://"]){
url2 = [NSURL URLWithString:urlTwo];
}else{
url2 = [NSURL URLWithString:[NSString stringWithFormat:@"http://%@" , urlTwo]];
}
NSLog(@"url2:%@", url2);
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url2];
[webView loadRequest:requestObj];
[[self view] addSubview:webView];
}
}
}
@catch (NSException * e) {
NSLog(@"Exception: %@", e);
[self alertStatus:@"Login Failed." :@"Login Failed!" :0];
}
}
-(void)webViewDidStartLoad:(UIWebView *)webView{
NSLog(@"webViewDidStartLoad");
[self.view addSubview:self.indicator];
alert.hidden = NO;
}
- (void) webViewDidFinishLoad:(UIWebView *)webView {
NSLog(@"webViewDidFinishLoad");
[self.indicator removeFromSuperview];
[self.alert dismissWithClickedButtonIndex:1 animated:NO] ;
}
- (IBAction)backgroundClick:(id)sender
{
[txtsecurecode resignFirstResponder];
[OrganizationCode resignFirstResponder];
}
@end
콘텐츠가 webview에 표시 될 때까지 이미지로드 및 표시가 제대로 작동합니다. 하지만 webview의 내용은 편집 가능하지 않고 정적 인 채로 남아 있습니다. 'web view.hidden = YES'를 사용했다고 생각합니다. 경고 메소드에 주석을 달고 웹 뷰의 컨텐츠를 편집하면 필요에 따라 편집 및 작업이 가능합니다. 로드하는 이미지가로드를 중지 한 후 url의 내용을로드해야합니다. 누구든지 문제 해결을 도울 수 있습니까? 미리 감사드립니다. 내가 제안
중요하다. – nil