#import "LoginVC.h"
#import "HOMEVC.h"
#import "DashboardVC.h"
@interface LoginVC()
@end
@implementation LoginVC
UIActivityIndicatorView *spinner ;
-(IBAction)login:(id)sender{
NSString *userUpdate =[NSString stringWithFormat:@"%@",[Usernamefileld text]];
NSString *userUpdate1 =[NSString stringWithFormat:@"%@",[PasswordField text]];
NSString *baseURL = [NSString stringWithFormat:@"http://192.168.1.200:8094/YazakiService.svc/LOGIN/%@/%@",userUpdate,userUpdate1];
NSURL *url = [NSURL URLWithString:[baseURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
NSURLResponse *response;
NSError *error;
NSData *responseData =[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSMutableArray *serviceResponse=[NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&error];
NSLog(@"got response==%@", serviceResponse);
NSDictionary *template=[serviceResponse objectAtIndex:0];
NSString *test=[template objectForKey:@"ValidState"];
// NSString *test1=[template objectForKey:@"Userid"];
NSString *helloString = @"1";
// //
// NSString *helloString1 [email protected]"LFY430";
if ([test isEqual:helloString]) {
[NSThread detachNewThreadSelector:@selector(threadStartAnimating:) toTarget:self withObject:nil];
[self moveToView];
// UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Login Successfully" message:@"Correct Uername/Password" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
}
else{
UIAlertView *alert2=[[UIAlertView alloc]initWithTitle:@"Login Failed" message:@"Incorrect Uername/Password" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
[alert2 show];
[self alertView1:alert2 didDismissWithButtonIndex:alert2];
}
}
- (void)viewDidLoad {
[super viewDidLoad];
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(150, 225, 20, 30)];
[spinner setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleGray];
spinner.color = [UIColor blackColor];
[self.view addSubview:spinner];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
-(void)moveToView{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
DashboardVC *initView = (DashboardVC*)[storyboard instantiateViewControllerWithIdentifier:@"Dashboardvc"];
[initView setModalPresentationStyle:UIModalPresentationFullScreen];
[spinner stopAnimating];
[self presentViewController:initView animated:NO completion:nil];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
[self moveToView];
}
- (void) alertView1:(UIAlertView *)alertView1 didDismissWithButtonIndex:(NSInteger)buttonIndex
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
LoginVC *initView = (LoginVC*)[storyboard instantiateViewControllerWithIdentifier:@"loginvc"];
[initView setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentViewController:initView animated:NO completion:nil];
}
-(void)threadStartAnimating:(id)data
{
[spinner startAnimating];
}
@end
hier hinzufügen müssen, indem ich die Anzeige initialse und starten und die Spinner zu stoppen, aber es ist nicht für mich woking ... jemand mir helfen, die Fragen, wie man hinzufügen die lösen Aktivitätsanzeige, wenn die Navigation die eine andere Ansichtwenn Navigieren Sie durch die andere Seite Aktivitätsanzeige
Vielen Dank im Voraus
warum u hat der Aufruf der Methode in falschen Ort –
u kann mir helfen, die Probleme zu beheben – fathima
aber Ihr Code synchrone Methode, wie seine Werke Schwester –