登录界面制作以及设备版本号上传

#import <UIKit/UIKit.h>

#import "SRWebSocket.h"

@interface ViewController : UIViewController<UITextFieldDelegate,SRWebSocketDelegate>

//- (IBAction)SaveLogin:(id)sender;

@property (weak, nonatomic) IBOutlet UITextField *userName;

@property (weak, nonatomic) IBOutlet UITextField *password;

@property (weak, nonatomic) IBOutlet UIImageView *logoImage;

- (IBAction)loginbuttonClick:(id)sender;

@property (weak, nonatomic) IBOutlet UIButton *loginButton;

//@property (weak, nonatomic) IBOutlet UIButton *SaveLogin;

@property (weak, nonatomic) IBOutlet UILabel *lbuser;

@property (weak, nonatomic) IBOutlet UILabel *lbpassword;

@end

#import "ViewController.h"

#import "ASIHTTPRequest.h"

#import "MD5.h"

#import "SVProgressHUD.h"

#import "Reachability.h"

#import "UIColor+Extensions.h"

#import "comm.h"

#import "UIDevice+IdentifierAddition.h"

#import <sys/utsname.h>

@interface ViewController ()

{

UIImageView *slashimage;

}

@property (weak, nonatomic) IBOutlet UITextView *serverMessage;

@property (weak, nonatomic) IBOutlet UITextField *input;

@property (weak, nonatomic) IBOutlet UILabel *connectStatus;

@property (nonatomic, readwrite) SRWebSocket *warbleSocket;

@property (nonatomic, readwrite) BOOL socketReady;

@end

@implementation ViewController

- (void)viewDidLoad

{

[super viewDidLoad];

CGSize viewSize = [[UIScreen mainScreen] bounds].size;

UIImageView *image = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"bg.png"]];

//[image setFrame:self.view.frame];

[image setFrame:CGRectMake(0, 0, viewSize.width, viewSize.height)];

[self.view addSubview:image];

[self.view sendSubviewToBack:image];

// Do any additional setup after loading the view, typically from a nib.

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillShow:) name:UIKeyboardWillShowNotification object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillHide:) name:UIKeyboardWillHideNotification object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldChanged:) name:UITextFieldTextDidChangeNotification object:nil];

self.userName.delegate = self;

self.password.delegate = self;

[self.navigationController.navigationBar setHidden:YES];

NSUserDefaults *pref = [NSUserDefaults standardUserDefaults];

NSString* strUid = [pref stringForKey:@"uid"];

NSString* strPwd = [pref stringForKey:@"pwd"];

self.userName.text = strUid;

self.password.text = strPwd;

self.userName.textColor = [UIColor colorWithHexString:@"767676"];

self.password.textColor = [UIColor colorWithHexString:@"767676"];

if ([self.userName.text isEqualToString:@""] || [self.password.text isEqualToString:@""])

{

[self.loginButton setEnabled:FALSE];

self.loginButton.titleLabel.textColor = [UIColor grayColor];

}

else

{

[self.loginButton setEnabled:TRUE];

self.loginButton.titleLabel.textColor = [UIColor whiteColor];

}

self.lbuser.backgroundColor = [UIColor colorWithHexString:@"b5b5b5"];

self.lbpassword.backgroundColor = [UIColor colorWithHexString:@"b5b5b5"];

self.loginButton.layer.borderWidth = 1.0f;

self.loginButton.layer.borderColor = [[UIColor whiteColor] CGColor];

self.loginButton.layer.cornerRadius = 4.0;

self.loginButton.titleLabel.textColor = [UIColor whiteColor];

self.loginButton.backgroundColor = [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:0.15];

//just test

//[self performSegueWithIdentifier:@"gotoHome" sender:self.loginButton];

//    slashimage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"[email protected]"]];

//    [slashimage setFrame:self.view.frame];

//    [self.view addSubview:slashimage];

//

//    [self performSelector:@selector(hideSlashImage) withObject:nil afterDelay:1.0];

[pref setValue:@"" forKey:@"CurrentChatContact"];

}

- (void)hideSlashImage

{

[UIView animateWithDuration:0.8 animations:^{

slashimage.alpha = 0.0;

} completion:^(BOOL finished) {

[slashimage removeFromSuperview];

}];

}

- (void) viewWillAppear:(BOOL)animated

{

CGSize viewSize = [[UIScreen mainScreen] bounds].size;

NSUserDefaults *pref = [NSUserDefaults standardUserDefaults];

NSString* strUid = [pref stringForKey:@"uid"];

NSString* strPwd = [pref stringForKey:@"pwd"];

self.userName.text = strUid;

self.password.text = strPwd;

[[NSNotificationCenter defaultCenter]

addObserver:self

selector:@selector(applicationDidBecomeActiveNotification:)

name:UIApplicationDidBecomeActiveNotification

object:[UIApplication sharedApplication]];

}

- (void) viewWillDisappear:(BOOL)animated

{

}

- (void)applicationDidBecomeActiveNotification:(NSNotification *)notification {

// Do something here

[self.userName resignFirstResponder];

[self.password resignFirstResponder];

}

- (void)viewDidAppear:(BOOL)animated

{

}

- (void)didReceiveMemoryWarning

{

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

- (NSString*) machineName

{

struct utsname systemInfo;

uname(&systemInfo);

return [NSString stringWithCString:systemInfo.machine

encoding:NSUTF8StringEncoding];

}

- (IBAction)loginbuttonClick:(id)sender

{

NSString *strBundleVersion = [NSString stringWithFormat:@"%@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]];

NSString *tmpmodel = [[UIDevice currentDevice] model];

//    NSString* model = [tmpmodel stringByReplacingOccurrencesOfString:@" " withString:@"_"]; //不能有空格

NSString *deviceid = [[UIDevice currentDevice] uniqueGlobalDeviceIdentifier];

NSString *version = [[UIDevice currentDevice] systemVersion];

NSString *devicetype = [[NSString alloc] initWithFormat:@"%@_%@_%@",deviceid, [self machineName],version];

//向管理平台登录,获取token

NSString *strUrl = [NSString stringWithFormat:@"%@/login?tel=%@&pwd=%@&devicetype=%@&vs=%@",WEB_SERVER_HOST,

self.userName.text,[self.password.text MD5EncodedString],devicetype,strBundleVersion];

NSLog(@"%@",strUrl);

NSString *strMd5 = [NSString stringWithMD5EncodedString:@"19"];

NSURL *url = [NSURL URLWithString:strUrl];

__block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];

[request setCompletionBlock:^{

// Use when fetching text data

NSString *responseString = [request responseString];

NSLog(@"login result:%@",responseString);

NSError *error = nil;

NSData *jsonData = [responseString dataUsingEncoding:NSUTF8StringEncoding];

NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:jsonData options:kNilOptions error:&error];

NSString* msgCode = [dict objectForKey:@"code"];

if ([msgCode isEqualToString:@"200"]) {

NSLog(@"login success!");

NSString* token = [dict objectForKey:@"token"];

NSUserDefaults *pref = [NSUserDefaults standardUserDefaults];

[pref setValue:token forKey:@"logintoken"];

[pref setValue:self.userName.text forKey:@"uid"];

[pref setValue:self.password.text forKey:@"pwd"];

[pref setBool:TRUE forKey:@"login"];

//NSString *msgResult = [[dict objectForKey:@"result"] description];

[pref setValue:responseString forKey:@"loginresult"];

//[SVProgressHUD dismiss];

[self.userName resignFirstResponder];

[self.password resignFirstResponder];

[self performSegueWithIdentifier:@"gotoHome" sender:self.loginButton];

}

else {

[SVProgressHUD showErrorWithStatus:@"用户名或密码有误,请重新输入。"];

NSUserDefaults *pref = [NSUserDefaults standardUserDefaults];

[pref setBool:FALSE forKey:@"login"];

return;

}

NSLog(@"msgCode is %@",msgCode);

}];

[request setFailedBlock:^{

NSError *error = [request error];

NSLog(@"login result:%@",error.description);

UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"请检查您的网络后重试!" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];

[alert show];

}];

[request startAsynchronous];

}

#pragma mark - 键盘处理

#pragma mark 键盘即将显示

- (void)keyBoardWillShow:(NSNotification *)note{

CGRect rect = [note.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];

CGFloat ty = self.view.frame.size.height - rect.size.height;

CGFloat shift = ty - self.loginButton.frame.origin.y-self.loginButton.frame.size.height;

[UIView animateWithDuration:[note.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue] animations:^{

self.view.transform = CGAffineTransformMakeTranslation(0, shift);

}];

}

#pragma mark 键盘即将退出

- (void)keyBoardWillHide:(NSNotification *)note{

[UIView animateWithDuration:[note.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue] animations:^{

self.view.transform = CGAffineTransformIdentity;

}];

}

- (void)textFieldChanged:(NSNotification *)note{

if ([self.userName.text isEqualToString:@""] || [self.password.text isEqualToString:@""])

{

[self.loginButton setEnabled:FALSE];

self.loginButton.titleLabel.textColor = [UIColor grayColor];

}

else

{

[self.loginButton setEnabled:TRUE];

self.loginButton.titleLabel.textColor = [UIColor whiteColor];

}

}

- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender

{

//默认不跳转,等待登陆结果

NSUserDefaults *pref = [NSUserDefaults standardUserDefaults];

BOOL blogin = [pref boolForKey:@"login"];

if (blogin) {

return TRUE;

}

return FALSE;

}

// In a storyboard-based application, you will often want to do a little preparation before navigation

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender

{

// Get the new view controller using [segue destinationViewController].

// Pass the selected object to the new view controller.

}

@end

登录界面制作以及设备版本号上传

时间: 2024-08-03 09:22:39

登录界面制作以及设备版本号上传的相关文章

Android基础之——startActivityForResult启动界面并返回数据,上传头像

在android应用的开发过程中,经常会出现启动一个界面后填写部分内容后带着数据返回启动前的界面,最典型的应用就是登录过程.在很多应用程序的模块中,都有"我的"这个模块,在未登录状态下点击其中的某一项,就会弹出登录界面,登录完成后回到我的界面,会显示一些登录后的数据,这个功能的实现就要用到startActivityForResult. 下面通过一个小demo来说明一下startActivityForResult的使用,以及在实际开发中的一些应用. demo的效果图如下: 主界面布局:

cisco设备IOS上传、备份、设置启动IOS

注:在使用cisco设备上传下载中,必须使用TFTP协议,所以,需要知道需要一根网线和电脑,电脑上需要开启TFTP服务(可以在网上下载相关的TFTP软件),网线连接cisco设备的网口和电脑,并且确保电脑和cisco设备在同一个网段内.可以相互ping通 IOS备份: R#copy flash:XXX.bin tftp:192.168.0.2(电脑的IP地址)     //将需要备份的IOS复制到相应的电脑上 Address or name of remote hos []? 192.168.0

C#模拟请求,模拟登录,Cookie设置、文件上传等问题汇总

由于业务需求,最近需要模拟完成登陆某个网站,并上传所需要的文件.在开发途中,遇到了很多问题,现在,就我遇到的一些问题及解决办法说明如下,希望对遇到同样问题的人有所帮助.因为技术有限,可能有些内容并不完全正确或者理解有偏差,希望大家不要见怪,有不同的想法可以留言,我们共同学习,这也是我开始写博客的初衷之一. 模拟请求,首先我觉得我们需要明确的是,模拟那些请求,我们模拟请求要完成那些操作,就拿我上面的功能来说,我需要模拟登录某个网站,然后打开固定的页面,输入关键字,查找相关信息,然后上传所需要的文件

如何制作一张符合上传的照片

很多人在网上报名或者填写信息时被要求上传一定要求(如下要求)的照片,可是很多人根本不知道该如何处理一张已经照好的照片,已达到网上所要求的的那样.接下来,我给大家分享一下自己的经验: 要求:jpg,白底,9-20K之间,358*441px 方法:ps,截图,mop(Microsoft Office Picture Manager)制图,系统画图 目的:符合要求的照片 1.用ps打开原图,右击鼠标在弹出的菜单中选择"打开方式",使用ps打开,菜单栏中找到"图像",选择&

手把手教你制作AppPreview视频并上传到appStore进行审核

注意,你需要使用iMovie才能够制作AppPreview视频文件,用QuickTime录制的无效! 最终效果 1. 新建一个事件 2. 创建应用程序预览 3. 导入视频文件(该视频文件需要你用QuickTime事先进行录制,此处不赘述) 4. 导入音频文件 5. 将视频文件音频文件拖到编辑区域 6. 加载转场文件 7. 分离文件并添加转场文件 8. 剪辑结束 9. 导出并生成App Preview文件 注意: 导出文件的时候,需要选择正确的分辨率,否则提交不了(此处需要选择640x1136)

服务器登录界面出现提示框 “网络上有重名”

1.右键 我的电脑--属性,然后按下图顺序,修改下服务器的计算机名 ,然后重启就可以了.

上传应用

登录开发者中心:http://developer.apple.com/ 第零部分:本地生成密钥 1.打开mac的钥匙串访问        2.选择钥匙串的证书助理(有些可能是英文的)     3.点击继续后存储证书,自己记好这个文件的位置,一般我放桌面上... 第一部分:开发者证书 这儿需要注意的是"普通开发者的话,开发者证书只能是有一个." 1.选择"Certificates, Identifiers & Profiles" 也就是上图中我红色框2.选择&

Android将Library上传到jcenter超简单完整步骤以及遇到的各种坑

Android将Library上传到jcenter超简单完整步骤以及遇到的各种坑 在[玩转SQLite系列](七)打造轻量级ORM工具类SQLiteDbUtil操作数据库 中我们可以看到这个工具类的超简洁用法:只需要在gradle中引入: compile 'cn.bluemobi.dylan:sqlitelibrary:0.1' 即可使用,那么这到底是怎么回事?这个是Android项目所在jcenter的一个远程仓库.我们只需要将你的libray上传到jcenter即可,那么如和将一个项目上传到

java开发:分享一下百度ueditor和七牛的图片集成上传

做网站时,如果上传的图片量很大,现在不少人会选用七牛图片服务器.那么,今天就来说说如何把网站的图片上传与七牛的sdk集成的问题. jsp页面,实现图片上传的方式也很多,今天就来说下百度的编辑器:ueditor 首先要到官网去下载它,后面我也会附上源代码,需要的朋友可以下载. 我们新建一个项目:qndemo,然后将ueditor放到webroot目录下,截图如下: 另外,我们还要引入jar包: 前台页面,我们需要引用相关js,默认配置下,会加载出编辑效果,如下图: 这时候,我们上传的图片会保存在本