0
我現在正在開發一個iOS應用程序,我是初學者,我遵循了一個樹屋課程,並且實際上只用更多的輸入域來做同樣的事情。我試圖從我的signupviewcontroller註冊,但我一直得到alertview,我不明白這是怎麼可能的,而我已經指定 - 就像在課程中 - 只是顯示alertview時,其中一個輸入字段的長度即使在填寫每個輸入字段時,我都會收到此錯誤,誰能幫我解決這個問題?我一直在signupviewcontroller中獲取alertview
這裏是signup.m:
//
// SignUpViewControllerLeverancier.m
// SIKA
//
// Created by BLANCO on 25-04-14.
// Copyright (c) 2014 Sinan Karakurt. All rights reserved.
//
#import "SignUpViewControllerLeverancier.h"
#import <Parse/Parse.h>
@interface SignUpViewControllerLeverancier()
@end
@implementation SignUpViewControllerLeverancier
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (IBAction)signupLeverancier:(id)sender {
NSString *naamLeverancier = self.naamLeverancierField.text ;
NSString *telefoonLeverancier = [self.telefoonLeverancierField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *bedrijfsnaamLeverancier = self.bedrijfsnaamLeverancierField.text;
NSString *adresLeverancier = self.adresLeverancierField.text;
NSString *postcodeLeverancier = self.postcodeLeverancierField.text;
NSString *stadLeverancier = self.stadLeverancierField.text;
NSString *emailLeverancier = [self.emailLeverancierField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *wachtwoordLeverancier = [self.wachtwoordLeverancierField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([naamLeverancier length] == 0 ||
[telefoonLeverancier length] == 0 ||
[bedrijfsnaamLeverancier length] == 0 ||
[adresLeverancier length] == 0 ||
[postcodeLeverancier length] == 0 ||
[stadLeverancier length] == 0 ||
[emailLeverancier length] == 0 ||
[wachtwoordLeverancier length] == 0)
{
UIAlertView *alertView = [[ UIAlertView alloc] initWithTitle:@"Leeg veld" message:@"Vul de lege velden in" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alertView show];
}
else {
PFUser *newUserLeverancier = [PFUser user];
newUserLeverancier[@"naamLeverancier"] = naamLeverancier;
newUserLeverancier[@"telefoonLeverancier"]= telefoonLeverancier;
newUserLeverancier.username = bedrijfsnaamLeverancier;
newUserLeverancier[@"adresLeverancier"] = adresLeverancier;
newUserLeverancier[@"postcodeLeverancier"] = postcodeLeverancier;
newUserLeverancier[@"stadLeverancier"] = stadLeverancier;
newUserLeverancier.email = emailLeverancier;
newUserLeverancier.password = wachtwoordLeverancier;
[newUserLeverancier signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (error) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sorry!" message:[error.userInfo objectForKey:@"error"] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
else {
[self.navigationController popToRootViewControllerAnimated:YES];
}
}];
}
}
@end
呃,很明顯你的一個字符串是空的?在方法中添加一個斷點並查看哪一個斷點。 –
告訴我們您已採取哪些措施來確定警報顯示的原因。到目前爲止你做了什麼? – Gruntcakes
不,即使填充字段,它也會給我這個警報視圖。我甚至嘗試過一場。 – user3394645