Ich habe im Rahmen meiner Hochschularbeit mit einem iPhone Projekt angefangen. Bin absoluter Neuanfänger und habe mich bis jetzt durch unterschiedliche Dokumentationen durch gelesen. Hänge aber leider hier fest. Kann mir mal jemand weiter helfen.Ich habe folgenden Code:
Alles anzeigen
Dies ist mein LoginScreen, in showData kommen meine Daten an, die per Request (eigene Delegate) zuvor gesendet wurden. Ich möchte anhand der Abfrage nun zur nächsten View wechseln. Wie geht das !? Was muss ich machen ?!
Ich habe den Wechsel zwar im Storyboard mit einer Segue gemacht aber der Wechsel findet immer statt, egal ob die Bedingung stimmt oder nicht.
Quellcode
- //
- // ViewController.m
- // JanJSon2
- //
- // Created by Emre on 04.06.12.
- // Copyright (c) 2012 __MyCompanyName__. All rights reserved.
- //
- #import "ViewController.h"
- #import "JSONKit.h"
- #import "SBJSON.h"
- #import "JSonSchnittstelle.h"
- #import "SearchViewController.h"
- @implementation ViewController
- @synthesize idField;
- @synthesize passwordField;
- @synthesize statusLabel;
- @synthesize activityIndicator;
- @synthesize logiButton;
- - (void) showData:(NSDictionary *)data{
- //NSLog(@"DataString: %@ ", data);
- NSLog(@"Test2");
- activityIndicator.hidden = TRUE;
- [activityIndicator stopAnimating];
- BOOL value = [[data valueForKey:@"authOk"]boolValue];
- NSLog(@"%@", value ? @"YES" : @"NO");
- if (value){
- [self performSegueWithIdentifier:@"toMainScreen" sender:self];
- }else {
- UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Fehler" message:(NSLocalizedString(@"LoginFailed", @"")) delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
- statusLabel.text = @"Id/Password is wrong";
- [alert show];
- [idField setUserInteractionEnabled:YES];
- [passwordField setUserInteractionEnabled:YES];
- }
- }
- -(BOOL)textFieldShouldReturn:(UITextField *)textField{
- NSLog(@"Next_Taste");
- if(textField == idField) {
- [passwordField becomeFirstResponder];
- }
- else
- [textField resignFirstResponder];
- return YES;
- }
- - (IBAction)sendRequest:(id)sender {
- [idField setUserInteractionEnabled:NO];
- [passwordField setUserInteractionEnabled:NO];
- //[logiButton setTitle:@"Anmeldung erfolgt" forState:UIControlStateNormal];
- [sender setTitle:@"Anmeldung erfolgt" forState:UIControlStateNormal];
- activityIndicator.hidden = FALSE;
- [activityIndicator startAnimating];
- loginId = idField.text;
- loginPassword = passwordField.text;
- JSonSchnittstelle *JSonSchnittstellenString = [[JSonSchnittstelle alloc]init];
- [JSonSchnittstellenString setDelegate:self];
- NSDictionary *JSonData1 = [JSonSchnittstellenString buildRequestString:loginId withData:loginPassword];
- //NSDictionary *JSonData = [JSonSchnittstellenString loginRequest:JSonData1];
- [JSonSchnittstellenString sendRequest:JSonData1];
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- // Do any additional setup after loading the view, typically from a nib.
- //delegate = self;
- activityIndicator.hidden = YES;
- }
- - (void)viewDidUnload
- {
- //[self setIdFiled:nil];
- //[self setIdPassword:nil];
- [super viewDidUnload];
- // Release any retained subviews of the main view.
- }
- - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
- {
- return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
- }
- @end
Dies ist mein LoginScreen, in showData kommen meine Daten an, die per Request (eigene Delegate) zuvor gesendet wurden. Ich möchte anhand der Abfrage nun zur nächsten View wechseln. Wie geht das !? Was muss ich machen ?!
Ich habe den Wechsel zwar im Storyboard mit einer Segue gemacht aber der Wechsel findet immer statt, egal ob die Bedingung stimmt oder nicht.