IOS learn

来源:互联网 发布:非法网络传销罪 编辑:程序博客网 时间:2024/05/31 13:14

//

//  QQLogInVC.m

//  MyQQ

//

//  Created by caokun on 9/24/13.

//  Copyright (c) 2013 tencent. All rights reserved.

//

#import "QQGlobolConfig.h"

#import "QQLogInVC.h"

#import "FindPasswordVC.h"

#import "AppDelegate.h"

//判断设备是否为iphone5

#define Screen_height   [[UIScreen mainScreen] bounds].size.height

#define Screen_width    [[UIScreen mainScreen] bounds].size.width

#define IsIPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640,1136), [[UIScreen mainScreen] currentMode].size) : NO)





@interface QQLogInVC ()

{

    UIView *boxView_;

    UIView *bottomBoxView_;

    BOOL isShowedMoreUserView;

}

@end


@implementation QQLogInVC


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if (self) {

        // Custom initialization

    }

    return self;

}


- (void)viewDidLoad

{

    [superviewDidLoad];

// Do any additional setup after loading the view.

    

    UIView *contentView =[[UIViewalloc]initWithFrame:CGRectMake(0,0,Screen_width, Screen_height)];

    self.view=contentView;

    

    [contentView release];

    

    

    

    

    //bg

    UIImageView *bgImagineView=[[UIImageViewalloc]initWithFrame:CGRectMake(0,0,Screen_width, Screen_height)];

    

    [bgImagineView setImage:[UIImageimageNamed:IsIPhone5?@"login_bg_ip5@2x.jpg":@"login_bg.jpg"]];

    

    [self.view addSubview:bgImagineView];

    [bgImagineView release];

    //avater header

    UIImageView *bAvatar=[[UIImageViewalloc]initWithFrame:CGRectMake(126,50,68, 68)];

    [bAvatar setImage:[UIImageimageNamed:@"login_avatar_default@2x.png"]];

    

    UIImageView *avatarView=[[UIImageViewalloc]initWithFrame:CGRectMake(2,2,64, 64)];

    

    [avatarView setImage:[UIImageimageNamed:@"login_avatar_default@2x.png"]];

    

    [bAvatar addSubview:avatarView];

    [avatarView release];

    [self.view addSubview:bAvatar];

    

    

    boxView_=[[UIViewalloc]initWithFrame:CGRectMake(8,120,304,200)];

    //top

    UIView *topBoxView=[[UIViewalloc]initWithFrame:CGRectMake(0,0,304, 50)];

    UIImageView *inputTopBg=[[UIImageViewalloc]initWithFrame:CGRectMake(0,0,304, 50)];

    [inputTopBg setImage:[UIImageimageNamed:@"login_textfield_top@2x.png"]];

    [topBoxView addSubview:inputTopBg];

    [inputTopBg release];

    

    

    UILabel *userNumLable=[[UILabelalloc]initWithFrame:CGRectMake(5,10,60, 35)];

    [userNumLable setText:@"账号"];

    UITextField *userNumField=[[UITextFieldalloc]initWithFrame:CGRectMake(60,10,220, 35)];

    

    [userNumField addTarget:selfaction:@selector(hiddenKeyBorad:)forControlEvents:UITextFieldTextDidEndEditingNotification];

   

    

    [userNumField setBorderStyle:UITextBorderStyleLine];

    [topBoxView addSubview:userNumLable];

    [topBoxView addSubview:userNumField];

    [userNumField release];

    [userNumLable release];

    

    UIButton *listUserBtn=[UIButtonbuttonWithType:UIButtonTypeCustom];

    [listUserBtn setBackgroundImage:[UIImageimageNamed:@"login_textfield_more@2x.png"]forState:UIControlStateNormal];

    [listUserBtn setFrame:CGRectMake(265,20,15, 9)];

    [listUserBtn addTarget:selfaction:@selector(listUserBtnClicked:)forControlEvents:UIControlEventTouchUpInside];

    [topBoxView addSubview:listUserBtn];

    

    

    //bottom

    bottomBoxView_=[[UIViewalloc]initWithFrame:CGRectMake(0,50,304,120)];

    UIImageView *line=[[UIImageViewalloc]initWithFrame:CGRectMake(0,2,300,2)];

    [line setImage:[UIImageimageNamed:@"login_textfield_mid@2x.png"]];

    [bottomBoxView_ addSubview:line];

    [line release];

    UIImage *bottomImage=[UIImageimageNamed:@"login_textfield_bottom@2x.png"];

    UIImage *bottomImage2=[bottomImage resizableImageWithCapInsets:UIEdgeInsetsMake(4,4,4, 4)];

    //

    UIImageView *inputDownBg=[[UIImageViewalloc]initWithFrame:CGRectMake(2,1,302, 50)];

    [inputDownBg setImage:bottomImage2];

    [bottomBoxView_ addSubview:inputDownBg];

    [inputDownBg release];

    

    UILabel *userPassLable=[[UILabelalloc]initWithFrame:CGRectMake(5,10,60, 35)];

    [userPassLable setText:@"密码"];

    UITextField *userPassField=[[UITextFieldalloc]initWithFrame:CGRectMake(70,10,250, 35)];

    [userPassField addTarget:selfaction:@selector(hiddenKeyBorad:)forControlEvents:UITextFieldTextDidEndEditingNotification];

    [bottomBoxView_ addSubview: userPassLable];

    [bottomBoxView_ addSubview:userPassField];

    

    [userPassField release];

    [userPassLable release];

    

    

    UIButton *loginBtn=[UIButtonbuttonWithType:UIButtonTypeCustom];

    [loginBtn setFrame:CGRectMake(5,70,294 ,44)];

    [loginBtn setBackgroundImage:[UIImageimageNamed:@"login_btn_blue_nor@2x.png"]forState:UIControlStateNormal];

    

    [loginBtn setBackgroundImage:[UIImageimageNamed:@"login_btn_blue_press@2x.png"]forState:UIControlStateHighlighted];

    [loginBtn addTarget:selfaction:@selector(loginBtnClicked:)forControlEvents:UIControlEventTouchUpInside];

    [bottomBoxView_ addSubview:loginBtn];

    

    

    [boxView_ addSubview:topBoxView];

    [topBoxView release];

    

    [boxView_ addSubview:bottomBoxView_];

    

    

    [self.view addSubview:boxView_];

    isShowedMoreUserView=NO;

    

    

    //找回密码

    


//    

    UILabel *findPassword=[[UILabelalloc]initWithFrame:CGRectMake(50,400,100, 50)];

    [findPassword setText:@"找回密码"];

    [findPassword setBackgroundColor:[UIColorclearColor]];

    UIButton *findPasswordbtn=[UIButtonbuttonWithType:UIButtonTypeCustom];

    [findPasswordbtn setBackgroundColor:[UIColorclearColor]];

    [findPasswordbtn setFrame:CGRectMake(50,400,100, 50)];

    [findPasswordbtn addTarget:selfaction:@selector(findPasswordClicked:)forControlEvents:UIControlEventTouchUpInside];

    

    

    

    

    [self.view addSubview:findPassword];

    [self.view addSubview:findPasswordbtn];

     

    // [[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];

    //文本输入结束退出出软键盘

    


   


}


- (void)didReceiveMemoryWarning

{

    [superdidReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

    

}

#pragma mark 按钮点击事件处理



-(void)findPasswordClicked:(id)sender

{

    NSLog(@"找回密码");

    FindPasswordVC *findpass=[[[FindPasswordVCalloc]init]autorelease];

    

    [[AppDelegatesharedAppDelegate].rootNavpushViewController:findpassanimated:YES];

    

}

-(void)hiddenKeyBorad:(id)sender

{

    [sender resignFirstResponder];

}




-(void)loginBtnClicked:(id)sender

{

    NSLog(@"");

}

//显示最近登录用户。

-(void)listUserBtnClicked:(id)sender

{

    if (isShowedMoreUserView) {

        isShowedMoreUserView=NO;

        [UIViewbeginAnimations:@"HiddenMoreUser"context:NULL];

        [UIViewsetAnimationDuration:0.25f];

        [bottomBoxView_ setFrame:CGRectMake(0,50,304, 120)];

        [UIViewcommitAnimations];

        

    }else{

        isShowedMoreUserView=YES;

        [UIView beginAnimations:@"ShowMoreUser" context:NULL];

        [UIView setAnimationDuration:0.25f];

        [bottomBoxView_ setFrame:CGRectMake(0,50+100,304,120)];

        [UIView commitAnimations];

    }

}


@end




//

//  FindPasswordVC.m

//  MyQQ

//

//  Created by caokun on 9/24/13.

//  Copyright (c) 2013 tencent. All rights reserved.

//


#import "FindPasswordVC.h"

#import "QQGlobolConfig.h"

@interface FindPasswordVC ()

{

    UIWebView *wView;

    UIActivityIndicatorView *waitView_;


}

@end


@implementation FindPasswordVC


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if (self) {

        // Custom initialization

    }

    return self;

}


-(void)loadView

{

    UIView *contentView=[[UIViewalloc]initWithFrame:CGRectMake(0,0,Screen_width ,Screen_height)];

    

    self.view=contentView;

    [contentView release];

    

     wView=[[UIWebViewalloc]initWithFrame:CGRectMake(0,0,Screen_width ,Screen_height)];

     wView.delegate=self;

    [self.view addSubview:wView];

    

    //设置小菊花

     waitView_=[[UIActivityIndicatorViewalloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];

    [waitView_setFrame:CGRectMake(140,200,30,30)];

    [self.view addSubview:waitView_];

    [waitView_ setHidden:YES];

    

}


- (void)viewDidLoad

{

    [superviewDidLoad];

// Do any additional setup after loading the view.

     self.navigationController.navigationBarHidden=NO;//rootnavi显示   以便于返回。

     [wViewloadRequest:[NSURLRequestrequestWithURL:[NSURLURLWithString:@"http://www.baidu.com"]]];

}

- (void)webViewDidStartLoad:(UIWebView *)webView

{

    NSLog(@"------->");

    [waitView_ setHidden:NO];

    [waitView_startAnimating];

}

- (void)webViewDidFinishLoad:(UIWebView *)webView

{

    NSLog(@"----finished--->");

    [waitView_ setHidden:YES];

    [waitView_stopAnimating];

}


- (void)didReceiveMemoryWarning

{

    [superdidReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}


@end

//

//  AppDelegate.m

//  MyQQ

//

//  Created by caokun on 9/24/13.

//  Copyright (c) 2013 tencent. All rights reserved.

//


#import "AppDelegate.h"

#import "QQLogInVC.h"


@implementation AppDelegate


@synthesize rootNav=rootNav_;


- (void)dealloc

{

    [_window release];

    [super dealloc];

}

+(AppDelegate*)sharedAppDelegate

{

    return (AppDelegate*)[UIApplicationsharedApplication].delegate;

}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

    self.window = [[[UIWindowalloc]initWithFrame:[[UIScreenmainScreen]bounds]] autorelease];

    // Override point for customization after application launch.

    

    rootNav_=[[UINavigationControlleralloc]init];

    rootNav_.navigationBarHidden=YES;

    QQLogInVC *logInVC=[[QQLogInVCalloc]init];

    [rootNav_pushViewController:logInVCanimated:NO];

    

    

    self.window.rootViewController=rootNav_;

    

    self.window.backgroundColor = [UIColorwhiteColor];

    [self.windowmakeKeyAndVisible];

    return YES;

}


- (void)applicationWillResignActive:(UIApplication *)application

{

    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.

    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.

}


- (void)applicationDidEnterBackground:(UIApplication *)application

{

    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 

    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.

}


- (void)applicationWillEnterForeground:(UIApplication *)application

{

    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.

}


- (void)applicationDidBecomeActive:(UIApplication *)application

{

    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.

}


- (void)applicationWillTerminate:(UIApplication *)application

{

    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.

}


@end


原创粉丝点击