当前位置:编程学习 > wap >>

ios开发闪退,注销后重新登录闪退,连续动画

最近在做一个需要联网登录的项目,想把登录界面和登录过程做得好看一点,于是就写了很多的连续动画,第一次登录是没有问题的,但是之后注销重新登录就闪退了,是点击登录按钮的时候闪退了,但是我在那个按钮的action里面的第一行打了一个log都没有输出,也没有输出任何错误信息,崩溃日志我又看不懂····而且只在真机上运行出问题,模拟器上没问题,不知道是哪里出了问题,求大神帮看看!!!
下面是崩溃日志和登录页面的代码···


#import "LoginViewController.h"
#import "LoginResult.h"
#import "Dao.h"
#import "Reachability.h"
#import "CheckNetwork.h"
BOOL keyBoardIsAppear;
BOOL shouldLogin;

@interface LoginViewController ()

@end

@implementation LoginViewController

@synthesize PhoneNumberTF;
@synthesize ExitButton;
@synthesize LoginButton;
@synthesize PasswordTF;
@synthesize loginView;
@synthesize backgroundIV;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    keyBoardIsAppear = NO;
    shouldLogin = NO;
    PhoneNumberTF.delegate = self;
    PasswordTF.delegate = self;
//    [PhoneNumberTF setText:@"13903057121"];
//    [PasswordTF setText:@"888168998"];
    PasswordTF.secureTextEntry = YES;
    
    [super viewDidLoad];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                              selector:@selector(reachabilityChanged:)
                                                  name:kReachabilityChangedNotification
                                                object:nil];
    
     
     Reachability * reach = [Reachability reachabilityWithHostname:@"www.baidu.com"];
     
     [reach startNotifier];

    
     
//    [self waitAppear];
    NSThread *thread = [[NSThread alloc]initWithTarget:self selector:@selector(waitAppear) object:nil];
    [thread start];
// Do any additional setup after loading the view.
}
//wait 5 seconds to open animation
- (void)waitAppear
{
    
    [NSThread sleepForTimeInterval:1.0];
    [self performSelectorOnMainThread:@selector(appearAnimBegin) withObject:nil waitUntilDone:YES];
//    NSLog(@"aaa");
}
//登陆框出现
- (void)appearAnimBegin
{
//    NSLog(@"sss");
    [self dimImageAppear:backgroundIV];
    [self loginViewAppear:loginView];
}
//登录框消失
- (void)disappearAnimBegin
{
//    NSLog(@"disappear");
    [self dimImageDisappear:backgroundIV];
    [self loginViewDisappear:loginView];
}
//模糊效果出现
-(void)dimImageAppear:(UIImageView *)imageView
{
    
    [UIView beginAnimations:@"dimAppear" context:nil];
    [UIView setAnimationDuration:0.5];
    imageView.alpha = 1;
    [UIView commitAnimations];
    
}

-(void)loginViewAppear:(UIView *)view
{
    
    CGRect rect = view.frame;
    rect.origin.y -= 30;
    [UIView beginAnimations:@"loginAppear" context:nil];
    [UIView setAnimationDuration:0.5];
    view.alpha = 1;
    view.frame = rect;
    [UIView commitAnimations];
    
}

-(void)dimImageDisappear:(UIImageView *)imageView
{
    [UIView beginAnimations:@"dimDisappear" context:nil];
    [UIView setAnimationDuration:0.3];
    imageView.alpha = 0;
    [UIView commitAnimations];

}


-(void)loginViewDisappear:(UIView *)view
{
    
    CGRect rect = view.frame;
    rect.origin.y += 30;
    [UIView beginAnimations:@"loginDisappear" context:nil];
    [UIView setAnimationDuration:0.3];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(JumpToMainPage)];
    view.alpha = 0;
    view.frame = rect;
    [UIView commitAnimations];
    
    
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)LoginAction:(id)sender {
    

    NSString *phoneNumber = PhoneNumberTF.text;
    NSString *password = PasswordTF.text;
    NSDictionary *dic = [[NSDictionary alloc]initWithObjectsAndKeys:phoneNumber,@"phoneNum",password,@"password", nil];
    [PhoneNumberTF resignFirstResponder];
    [PasswordTF resignFirstResponder];
    NSThread *loginThread = [[NSThread alloc]initWithTarget:self selector:@selector(loginThreadSelector:) object:dic];
    [loginThread start];
}

- (void)loginThreadSelector:(NSDictionary *)loginInfo{
    NSString *phoneNumber = (NSString *)[loginInfo objectForKey:@"phoneNum"];
    NSString *password = (NSString *)[loginInfo objectForKey:@"password"];
    if ([phoneNumber length] == 0 || [password length] == 0) {
        [self textFieldDidEndEditing:PasswordTF];
        [self earthquake:loginView];
        return;
    }
    
    if (![CheckNetwork getIsConnected]) {
        [self textFieldDidEndEditing:PasswordTF];
        [self earthquake:loginView];
        UIAlertView*alertView = [[UIAlertView alloc]initWithTitle:@"温馨提示"
                                                          message:@"检测到无网络环境,是否脱机运行?"
                                                         delegate:nil
                                                cancelButtonTitle:@"是"
                                                otherButtonTitles:@"否",nil];
        alertView.delegate = self;
        [alertView show];
        return;
    }

    
    Dao *share = [Dao sharedDao];
    LoginResult *LR = [share requestForLogin:phoneNumber password:password];
    if (LR.isSuccess > 0) {
        shouldLogin = YES;
        NSLog(@"login");
        [self textFieldDidEndEditing:PasswordTF];
//        [self disappearAnimBegin];
    }
    else{
        [self textFieldDidEndEditing:PasswordTF];
        [self earthquake:loginView];
    }
}

-(void)reachabilityChanged:(NSNotification*)note
{
    Reachability * reach = [note object];
    
    if([reach isReachable])
    {
        NSLog(@"Notification Says Reachable");
//        isConnected = YES;
        [CheckNetwork setIsConnected:YES];
    }
    else
    {
        NSLog(@"Notification Says Unreachable");
//        isConnected = NO;
        [CheckNetwork setIsConnected:NO];
        UIAlertView*alertView = [[UIAlertView alloc]initWithTitle:@"温馨提示"
                                                          message:@"网络连接失败,请检查网络"
                                                         delegate:nil
                                                cancelButtonTitle:@"确定"
                                                otherButtonTitles:nil];
        [alertView show];
    }

}

#pragma mark alertView
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    //    NSLog(@"%d",buttonIndex);
    if (buttonIndex == 0) {
        
        [self performSegueWithIdentifier:@"JumpToMainPage" sender:nil];
        
    }
}



-(void)earthquake:(UIView*)itemView
{
    CGFloat t =8.0;
    
    CGAffineTransform leftQuake  =CGAffineTransformTranslate(CGAffineTransformIdentity, t,0);
    CGAffineTransform rightQuake =CGAffineTransformTranslate(CGAffineTransformIdentity,-t, 0);
    
    itemView.transform = leftQuake;  // starting point
    
    [UIView beginAnimations:@"earthquake" context:(__bridge void *)(itemView)];
    [UIView setAnimationRepeatAutoreverses:YES];// important
    [UIView setAnimationRepeatCount:3];
    [UIView setAnimationDuration:0.08];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(earthquakeEnded:finished:context:)];
    
    itemView.transform = rightQuake;// end here & auto-reverse
    
    [UIView commitAnimations];
}

-(void)earthquakeEnded:(NSString*)animationID finished:(NSNumber*)finished context:(void*)context
{
    if([finished boolValue])
    {
        UIView* item =(__bridge UIView*)context;
        item.transform =CGAffineTransformIdentity;
    }
}



- (void)JumpToMainPage
{

//    [self textFieldDidEndEditing:PhoneNumberTF];
//    [self textFieldDidEndEditing:PasswordTF];
    [self performSegueWithIdentifier:@"JumpToMainPage" sender:nil];
    

}

- (IBAction)ExitAction:(id)sender {
}

-(void) viewWillAppear:(BOOL)animated
{
    //    [PhoneNumberTF setText:@"13903057121"];
//    [PasswordTF setText:@"888168998"];
    keyBoardIsAppear = NO;
    shouldLogin = NO;
    [super viewDidLoad];
    

    //    [self waitAppear];
    NSThread *thread = [[NSThread alloc]initWithTarget:self selector:@selector(waitAppear) object:nil];
    [thread start];

}


#pragma Mark UITextFieldDelegate
// 下面两个方法是为了防止TextView让键盘挡住的方法
/*
 开始编辑UITextView的方法
 */
-(void) textFieldDidBeginEditing:(UITextField *)textField
{
    if (keyBoardIsAppear) {
        return;
    }
    NSLog(@"yes");
    keyBoardIsAppear = YES;
    
    CGRect curFrame=self.view.frame;
    [UIView animateWithDuration:0.3f animations:^{
        self.view.frame = CGRectMake(curFrame.origin.x - 200, curFrame.origin.y, curFrame.size.width, curFrame.size.height);
    }];
}

/**
 结束编辑UITextView的方法,让原来的界面还原高度
 */
-(void) textFieldDidEndEditing:(UITextField *)textField
{
    if (!keyBoardIsAppear) {
        if (shouldLogin) {
            [self disappearAnimBegin];
        }
        return;
    }
    
    NSLog(@"no");
    CGRect curFrame=self.view.frame;
    [UIView beginAnimations:@"drogDownKeyBoard" context:nil];
    [UIView setAnimationDuration:0.3];
    [UIView setAnimationDelegate:self];
    self.view.frame = CGRectMake(curFrame.origin.x + 200, curFrame.origin.y, curFrame.size.width, curFrame.size.height);
    if (shouldLogin) {
        NSLog(@"ddddddddddddd");
        [UIView setAnimationDidStopSelector:@selector(disappearAnimBegin)];
    }

    [UIView commitAnimations];
//    [UIView animateWithDuration:0.3f animations:^{
//        self.view.frame = CGRectMake(curFrame.origin.x + 200, curFrame.origin.y, curFrame.size.width, curFrame.size.height);
    
//    }];
    //self.view移回原位置
    
    keyBoardIsAppear = NO;
    shouldLogin = NO;
//    if (shouldLogin) {
    
//    }
}


@end
闪退 IOS 连续动画 第二次 msgSend --------------------编程问答-------------------- 除 --------------------编程问答--------------------
show the breakpoint navigator->点击加号->Add exception breakpoint.

然后连接到真机上面去调试吧。debug模式不出现问题,那就直接调试release模式。
补充:移动开发 ,  iPhone
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,