当我输入错误的密码时,显示屏会闪烁

时间:2013-10-23 06:11:10

标签: iphone xcode

记录时,当我输入错误的密码时,屏幕开始闪烁。这是代码:

-(void)ValidateUser
{
    if(userObj)
    {
        if([userObj.userPassword isEqualToString:_txtPassword.text])
        {
            PlistUtility *objPlist = [[PlistUtility alloc] init];
            NSDictionary *loginDict = [objPlist ReadPlist:@"LoginCheck"];
            NSString *isFirstTime = [loginDict objectForKey:@"isFirstTime"];
            NSMutableDictionary *updateLoginDict = [[NSMutableDictionary alloc] init];
            [updateLoginDict setValue:userObj.userId forKey:@"userId"];
            [updateLoginDict setValue:userObj.userName forKey:@"username"];
            sendLabelname = userObj.userName;


        NSUserDefaults * standardUserDefaults = [NSUserDefaults standardUserDefaults];
        [standardUserDefaults setObject:sendLabelname forKey:@"usernameLabel"];
        [standardUserDefaults synchronize];         



        [updateLoginDict setObject:_txtCompanyID.text forKey:@"companyId"];
        [updateLoginDict setObject:_txtCompanyName.text forKey:@"companyName"];

        [objPlist WritetoPlist:@"LoginCheck" withData:updateLoginDict];

        NSString *urlString = [NSString stringWithFormat:@"http://demo.creativethoughts.co.in/wifier/GetAllSavedWifi.php?userid=%@",userObj.userId];
        NSString *result = [Server ConnectToServer:urlString :nil :@"GET"];
        NSMutableArray *resultArray = [result JSONValue];
        NSMutableDictionary *wifiDict = [[NSMutableDictionary alloc]init];
        for(int i=0;i<[resultArray count];i++)
        {
            NSMutableDictionary *currentDict = [[NSMutableDictionary  alloc]init];
            currentDict = [resultArray objectAtIndex:i];
            MapWifi *objMappedWifi = [[MapWifi alloc]init];
            objMappedWifi.macAddress = [currentDict objectForKey:@"wifier_wifi_address"];
            objMappedWifi.wifiName = [currentDict objectForKey:@"wifier_wifi_name"];
            objMappedWifi.securityKey = [currentDict objectForKey:@"wifier_secret_pass"];
            [wifiDict setObject:objMappedWifi forKey:[currentDict objectForKey:@"wifier_wifi_address"]];
        }
        NSData *dataWifi = [NSKeyedArchiver archivedDataWithRootObject:wifiDict];
        [objPlist WriteDatatoPlist:@"AddedWifi" withData:dataWifi];
        if([isFirstTime isEqualToString:@"1"])
        {
            dispatch_async(dispatch_get_main_queue(), ^{
                [self performSegueWithIdentifier:@"terms" sender:self];
            });
        }
        else
        {
            [self performSegueWithIdentifier:@"home" sender:self];
        }
    }
    else
    {
        [self performSelectorInBackground:@selector(wrongPassword) withObject:nil];

      //  [self performSelectorOnMainThread:@selector(showAlertMessage) withObject:nil waitUntilDone:NO];
    }
}
else
{

    dispatch_async(dispatch_get_main_queue(), ^{
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Info" message:@"Please select a valid user" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
        [alert show];
    });


}
 [_loader stopAnimating];

}

-(void)wrongPassword
{
  dispatch_async(dispatch_get_main_queue(), ^{
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Info" message:@"Please enter a valid password." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
        [alert show];
 });

2 个答案:

答案 0 :(得分:0)

@try this code

-(void)wrongPassword
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Info" message:@"Please enter a valid password." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
    [alert show];
}

答案 1 :(得分:0)

错误在于UI元素选择器视图。密码出错时,它在后台线程上运行。我使用此代码在主线程中运行,问题得到修复

**dispatch_async(dispatch_get_main_queue(), ^{
        [self LoadActionSheet];
    });**