Initial commit
This commit is contained in:
BIN
Binary file not shown.
+15
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// AboutUsViewController.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 15/9/29.
|
||||
// Copyright © 2015年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "BaseVIewContorller.h"
|
||||
|
||||
@interface AboutUsViewController : BaseVIewContorller
|
||||
@property (weak, nonatomic) IBOutlet UILabel *versionLabel;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView *logoImg;
|
||||
|
||||
@end
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
//
|
||||
// AboutUsViewController.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 15/9/29.
|
||||
// Copyright © 2015年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AboutUsViewController.h"
|
||||
#import "IfishUDPBroadCastHelper.h"
|
||||
|
||||
@interface AboutUsViewController ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation AboutUsViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
self.view.backgroundColor=COLOR_BACK_;
|
||||
[self addTitleViewWithTitle:@"关于我们"];
|
||||
|
||||
//app 版本
|
||||
NSDictionary *infoDic=[[NSBundle mainBundle] infoDictionary];
|
||||
// CFShow((__bridge CFTypeRef)(infoDic));
|
||||
NSString *app_Version=[infoDic objectForKey:@"CFBundleShortVersionString"];
|
||||
NSLog(@"app_Version%@",app_Version);
|
||||
self.versionLabel.text=[NSString stringWithFormat:@"v%@",app_Version];
|
||||
//build 版本
|
||||
// NSString *app_build=[infoDic objectForKey:@"CFBundleVersion"];
|
||||
|
||||
[self addlongPress];
|
||||
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
}
|
||||
-(void)addlongPress{
|
||||
|
||||
UILongPressGestureRecognizer*longpress=[[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longpressRecongnizer:)];
|
||||
|
||||
longpress.minimumPressDuration = 3;
|
||||
|
||||
[self.view addGestureRecognizer:longpress];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
-(void)longpressRecongnizer:(UILongPressGestureRecognizer*)longPressGesture{
|
||||
|
||||
if (longPressGesture.state==UIGestureRecognizerStateEnded) {
|
||||
//logo 长安切换设备环境
|
||||
|
||||
CGPoint locationP= [longPressGesture locationInView:self.view];
|
||||
|
||||
BOOL isIn= CGRectContainsPoint( self.logoImg.frame ,locationP);
|
||||
|
||||
if (isIn) {
|
||||
|
||||
NSLog(@"3miao");
|
||||
[[IfishUDPBroadCastHelper sharedInstance] broadCaseUDP];
|
||||
[self.view makeToast:@"切换指令发送成功"];
|
||||
|
||||
}else{
|
||||
|
||||
|
||||
UIAlertView*alert=[[UIAlertView alloc]initWithTitle:@"哟,发现彩蛋了~" message:@"爱鱼奇初创团队:\n服务端攻城狮:郭恭文\n安卓美男子:欧阳达\nios宅男:练向\n射鸡师腐女:杨继莹\nios烟鬼:肖鸿宇\n软妹子UI:张馨妍\n骚男UI:吴磊磊\nCEO大大:欧阳国务\n产品汪:单志锋\n想要获得他们的联系方式,请长按100秒~" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
|
||||
[alert show];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
-(void)viewWillAppear:(BOOL)animated{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(void)viewDidDisappear:(BOOL)animated{
|
||||
[super viewDidDisappear:animated];
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="AboutUsViewController">
|
||||
<connections>
|
||||
<outlet property="logoImg" destination="eF7-2f-ZF7" id="Xhi-Ey-hNU"/>
|
||||
<outlet property="versionLabel" destination="mtD-B2-lG5" id="4Vr-3k-9Pw"/>
|
||||
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
|
||||
</connections>
|
||||
</placeholder>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" id="i5M-Pr-FkT">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="V1.1.4" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="mtD-B2-lG5">
|
||||
<rect key="frame" x="125" y="235" width="64" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="12"/>
|
||||
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="上海鱼影科技有限公司" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="I7q-C2-Jdn">
|
||||
<rect key="frame" x="51" y="515" width="212" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="12"/>
|
||||
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Copyright@www.iFish7.com All Rights Reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="EQ7-hy-FEN">
|
||||
<rect key="frame" x="17" y="539" width="281" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="11"/>
|
||||
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" userInteractionEnabled="NO" contentMode="scaleToFill" text=" 爱鱼奇团队是一群充满激情和梦想的年轻队伍,我们致力于在水族领域为大家提供好玩并贴心的产品和服务。" id="mz4-Xw-QCg">
|
||||
<rect key="frame" x="17" y="266" width="281" height="88"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
|
||||
</textView>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="logo200.png" id="eF7-2f-ZF7">
|
||||
<rect key="frame" x="117" y="93" width="80" height="80"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
|
||||
</imageView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="重新定义玩乐主义" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="3jW-T0-qIF">
|
||||
<rect key="frame" x="17" y="203" width="281" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="15"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<point key="canvasLocation" x="259" y="212"/>
|
||||
</view>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="logo200.png" width="200" height="200"/>
|
||||
</resources>
|
||||
</document>
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// ChangeMobleController.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 15/9/28.
|
||||
// Copyright © 2015年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "BaseVIewContorller.h"
|
||||
|
||||
@interface ChangeMobleController : BaseVIewContorller
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UITextField *sureTextFiled;
|
||||
|
||||
- (IBAction)netSteep:(id)sender;
|
||||
@property (weak, nonatomic) IBOutlet UITextField *yuanTelPhone;
|
||||
@property (weak, nonatomic) IBOutlet UIView *countryView;
|
||||
@property (weak, nonatomic) IBOutlet UIButton *coutryBtn;
|
||||
|
||||
@end
|
||||
+260
@@ -0,0 +1,260 @@
|
||||
//
|
||||
// ChangeMobleController.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 15/9/28.
|
||||
// Copyright © 2015年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ChangeMobleController.h"
|
||||
#import "UserModel.h"
|
||||
#import "AFNetworking.h"
|
||||
#import "ChangeModelDoneController.h"
|
||||
#import "XWCountryCodeController.h"
|
||||
@interface ChangeMobleController ()
|
||||
@property (weak, nonatomic) IBOutlet UIButton *timerbutton;
|
||||
@property (weak, nonatomic) IBOutlet UIButton *nextTepBtn;
|
||||
@property(nonatomic,copy)NSString*verifyData;
|
||||
@property(nonatomic,copy) NSString *areaCode;
|
||||
@end
|
||||
|
||||
@implementation ChangeMobleController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
self.areaCode = @"86";
|
||||
self.view.backgroundColor= [UIColor colorWithPatternImage:[UIImage imageNamed:@"enter_background"]];
|
||||
[self addTitleViewWithTitle:@"更换手机号"];
|
||||
//self.title = @"更换手机号";
|
||||
UserModel*model=[[DataCenter defaultDtacenter]valueForKey:@"UserLogIn"];
|
||||
NSMutableString*string=[[NSMutableString alloc]initWithString:model.phoneNumber];
|
||||
[string replaceCharactersInRange:NSMakeRange(3, 4) withString:@"***"];
|
||||
self.yuanTelPhone.text=string;
|
||||
[self.timerbutton addTarget:self action:@selector(startTime) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self textStyle];
|
||||
[self.coutryBtn addTarget:self action:@selector(countryCodeAction) forControlEvents:UIControlEventTouchUpInside];
|
||||
self.view.backgroundColor = [UIColor whiteColor];
|
||||
|
||||
|
||||
}
|
||||
-(void)textStyle{
|
||||
|
||||
self.nextTepBtn.backgroundColor=COLOR_LABEL_TITLE;
|
||||
self.timerbutton.backgroundColor=COLOR_LABEL_TITLE;
|
||||
|
||||
self.sureTextFiled.layer.masksToBounds=YES;
|
||||
self.sureTextFiled.layer.cornerRadius=5;
|
||||
self.timerbutton.layer.masksToBounds = YES;
|
||||
self.timerbutton.layer.cornerRadius = 5;
|
||||
self.nextTepBtn.layer.masksToBounds = YES;
|
||||
self.nextTepBtn.layer.cornerRadius = 5;
|
||||
self.yuanTelPhone.layer.masksToBounds = YES;
|
||||
self.yuanTelPhone.layer.cornerRadius = 5;
|
||||
self.countryView.layer.masksToBounds = YES;
|
||||
self.countryView.layer.cornerRadius = 5;
|
||||
|
||||
UIView*phoneView=[[UIView alloc]initWithFrame:CGRectMake(0,0, 10, 10)];
|
||||
self.yuanTelPhone.leftView=phoneView;
|
||||
self.yuanTelPhone.leftViewMode=UITextFieldViewModeAlways;
|
||||
UIView*phoneView1=[[UIView alloc]initWithFrame:CGRectMake(0,0, 10, 10)];
|
||||
self.sureTextFiled.leftView=phoneView1;
|
||||
self.sureTextFiled.leftViewMode=UITextFieldViewModeAlways;
|
||||
|
||||
}
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
}
|
||||
-(void)startTime{
|
||||
|
||||
__block int timeout=60; //倒计时时间
|
||||
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
|
||||
dispatch_source_t _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,queue);
|
||||
dispatch_source_set_timer(_timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //每秒执行
|
||||
dispatch_source_set_event_handler(_timer, ^{
|
||||
if(timeout<=0){ //倒计时结束,关闭
|
||||
dispatch_source_cancel(_timer);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
//设置界面的按钮显示 根据自己需求设置
|
||||
[_timerbutton setTitle:@"发送验证码" forState:UIControlStateNormal];
|
||||
_timerbutton.userInteractionEnabled = YES;
|
||||
});
|
||||
}else{
|
||||
// int minutes = timeout / 60;
|
||||
int seconds = timeout % 60;
|
||||
NSString *strTime=@"";
|
||||
if (seconds==0) {
|
||||
strTime=@"60";
|
||||
}else{
|
||||
strTime = [NSString stringWithFormat:@"%.2d", seconds];
|
||||
}
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
//设置界面的按钮显示 根据自己需求设置
|
||||
NSLog(@"____%@",strTime);
|
||||
[_timerbutton setTitle:[NSString stringWithFormat:@"%@秒",strTime] forState:UIControlStateNormal];
|
||||
_timerbutton.userInteractionEnabled = NO;
|
||||
_timerbutton.backgroundColor=[UIColor lightGrayColor];
|
||||
|
||||
});
|
||||
timeout--;
|
||||
|
||||
}
|
||||
});
|
||||
dispatch_resume(_timer);
|
||||
|
||||
[self getVerifycode];
|
||||
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - 获取验证码新(SMS)
|
||||
|
||||
-(void)getVerifycode{
|
||||
|
||||
UserModel*model=[[DataCenter defaultDtacenter]valueForKey:@"UserLogIn"];
|
||||
|
||||
// BOOL isMacth=[dataContorl valiMobile:model.phoneNumber];
|
||||
//
|
||||
// if (!isMacth) {
|
||||
//
|
||||
// [self.view makeToast:@"请输入正确手机号"];
|
||||
//
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// NSString *zone = [dataContorl areaCode:model.phoneNumber];
|
||||
//self.areaCode = zone;
|
||||
|
||||
[IFISHHTTPTOOL getverifyWithTimerButton:_timerbutton addphoneNumber:model.phoneNumber zone:self.areaCode result:^(NSError *err) {
|
||||
|
||||
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
|
||||
-(void)getAliVeriy{
|
||||
|
||||
|
||||
UserModel*model=[[DataCenter defaultDtacenter]valueForKey:@"UserLogIn"];
|
||||
|
||||
[AFHttpTool getSecurityCodeWithPhoneNumber:model.phoneNumber sendType:@"2" success:^(id response) {
|
||||
|
||||
if (response) {
|
||||
NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
||||
// self.sureTextFiled.text=reDic[@"data"];
|
||||
_verifyData=reDic[@"data"];
|
||||
// NSLog(@"_verifyData%@",_verifyData);
|
||||
if ([reDic[@"result"] isEqualToString:@"100"]) {
|
||||
|
||||
|
||||
[self showTitle:@"" messsage:@"发送成功"];
|
||||
|
||||
|
||||
}else if([reDic[@"result"] isEqualToString:@"101"]){
|
||||
[self showTitle:@"" messsage:@"获取验证失败"];
|
||||
// 获取验证失败
|
||||
}else if ([reDic[@"result"] isEqualToString:@"201"]){
|
||||
[self showTitle:@"" messsage:@"手机已经注册过"];
|
||||
}else{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} failure:^(NSError *err) {
|
||||
|
||||
UIAlertView *alter =[[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"请检查您的网络" delegate:self cancelButtonTitle:@"取消" otherButtonTitles: nil];
|
||||
[alter show];
|
||||
}];
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
- (IBAction)netSteep:(id)sender {
|
||||
UserModel*model=[[DataCenter defaultDtacenter]valueForKey:@"UserLogIn"];
|
||||
|
||||
|
||||
if (self.sureTextFiled.text.length==0) {
|
||||
|
||||
[self.view makeToast:@"验证码不能为空"];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
[SMSSDK commitVerificationCode:self.sureTextFiled.text phoneNumber:model.phoneNumber zone:self.areaCode result:^(SMSSDKUserInfo *userInfo, NSError *error) {
|
||||
|
||||
{
|
||||
if (!error)
|
||||
{
|
||||
|
||||
NSLog(@"验证成功");
|
||||
ChangeModelDoneController *done=[[ChangeModelDoneController alloc]init];
|
||||
[self.navigationController pushViewController:done animated:YES];
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"错误信息:%@",error);
|
||||
NSString *str =@"验证码验证失败";
|
||||
[self.view makeToast:str];
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
#pragma mark-处理收键盘
|
||||
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
|
||||
[textField resignFirstResponder];
|
||||
return YES;
|
||||
|
||||
}
|
||||
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
|
||||
[self hiddenKeybord];
|
||||
|
||||
}
|
||||
-(void)hiddenKeybord{
|
||||
[self.sureTextFiled resignFirstResponder];
|
||||
|
||||
}
|
||||
-(void)showTitle:(NSString*)title messsage:(NSString*)message{
|
||||
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:title message:message delegate:nil cancelButtonTitle:nil otherButtonTitles:nil, nil];
|
||||
NSTimeInterval dismissSeconds=1.0;
|
||||
[alert show];
|
||||
[self performSelector:@selector(dismissAlert:) withObject:alert afterDelay:dismissSeconds];
|
||||
|
||||
// UIAlertController *alertContorller=[UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
|
||||
// UIAlertAction*cancleAction=[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
|
||||
//
|
||||
// UIAlertAction *sureAction=[UIAlertAction actionWithTitle:@"好的" style:UIAlertActionStyleDefault handler:nil];
|
||||
// [alertContorller addAction:cancleAction];
|
||||
// [alertContorller addAction:sureAction];
|
||||
// [self presentViewController:alertContorller animated:YES completion:nil];
|
||||
|
||||
|
||||
}
|
||||
-(void)dismissAlert:(UIAlertView*)alertView{
|
||||
|
||||
[alertView dismissWithClickedButtonIndex:[alertView cancelButtonIndex] animated:YES];
|
||||
}
|
||||
|
||||
-(void)countryCodeAction
|
||||
{
|
||||
XWCountryCodeController *CountryCodeVC = [[XWCountryCodeController alloc] init];
|
||||
//CountryCodeVC.deleagete = self;
|
||||
|
||||
[CountryCodeVC toReturnCountryCode:^(NSString *countryCodeStr) {
|
||||
|
||||
[self.coutryBtn setTitle:countryCodeStr forState:UIControlStateNormal];
|
||||
|
||||
NSArray *array = [countryCodeStr componentsSeparatedByString:@"+"];
|
||||
self.areaCode = array[1];
|
||||
}];
|
||||
[self presentViewController:CountryCodeVC animated:YES completion:nil];
|
||||
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
|
||||
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ChangeMobleController">
|
||||
<connections>
|
||||
<outlet property="countryView" destination="zr1-cI-wIv" id="fI1-DZ-ToL"/>
|
||||
<outlet property="coutryBtn" destination="aDS-iZ-I7j" id="XA3-fG-ubR"/>
|
||||
<outlet property="nextTepBtn" destination="yfz-NH-iVG" id="MMz-LO-BWB"/>
|
||||
<outlet property="sureTextFiled" destination="Tzf-9e-1bw" id="49l-bv-d0A"/>
|
||||
<outlet property="timerbutton" destination="RMg-xc-HpK" id="aV5-D2-3YP"/>
|
||||
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
|
||||
<outlet property="yuanTelPhone" destination="5bx-Ia-Wcm" id="DgJ-JA-POD"/>
|
||||
</connections>
|
||||
</placeholder>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" id="i5M-Pr-FkT">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="kzp-eP-IHb">
|
||||
<rect key="frame" x="21" y="93" width="333" height="274"/>
|
||||
<subviews>
|
||||
<textField opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="请输入原手机号" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="5bx-Ia-Wcm">
|
||||
<rect key="frame" x="25" y="71" width="283" height="42"/>
|
||||
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" secondItem="5bx-Ia-Wcm" secondAttribute="height" multiplier="283:42" id="rTj-I9-GCF"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="请输入验证码" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Tzf-9e-1bw">
|
||||
<rect key="frame" x="25" y="121" width="283" height="42"/>
|
||||
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" secondItem="Tzf-9e-1bw" secondAttribute="height" multiplier="283:42" id="Mbf-Vc-ywW"/>
|
||||
</constraints>
|
||||
<color key="textColor" red="0.66666666666666663" green="0.66666666666666663" blue="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits" keyboardType="numberPad"/>
|
||||
</textField>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="yfz-NH-iVG">
|
||||
<rect key="frame" x="25" y="191" width="283" height="43"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" secondItem="yfz-NH-iVG" secondAttribute="height" multiplier="283:43" id="yRw-ss-x3m"/>
|
||||
</constraints>
|
||||
<state key="normal" title="下一步">
|
||||
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="netSteep:" destination="-1" eventType="touchUpInside" id="5Pq-my-RYg"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="RMg-xc-HpK">
|
||||
<rect key="frame" x="216" y="121" width="92" height="42"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="92" id="xAO-gJ-3i7"/>
|
||||
</constraints>
|
||||
<state key="normal" title="语音验证码">
|
||||
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</state>
|
||||
</button>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="zr1-cI-wIv">
|
||||
<rect key="frame" x="25" y="21" width="283" height="42"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="国家/地区" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="98K-4G-aUQ">
|
||||
<rect key="frame" x="8" y="11" width="73" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="15"/>
|
||||
<color key="textColor" red="0.59999999999999998" green="0.59999999999999998" blue="0.59999999999999998" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="aDS-iZ-I7j">
|
||||
<rect key="frame" x="104" y="6" width="166" height="30"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="166" id="nKQ-y7-S2C"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="15"/>
|
||||
<state key="normal" title="中国+86">
|
||||
<color key="titleColor" red="0.40000000000000002" green="0.40000000000000002" blue="0.40000000000000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</state>
|
||||
</button>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<constraints>
|
||||
<constraint firstItem="aDS-iZ-I7j" firstAttribute="centerY" secondItem="zr1-cI-wIv" secondAttribute="centerY" id="B2X-6d-kUT"/>
|
||||
<constraint firstAttribute="width" secondItem="zr1-cI-wIv" secondAttribute="height" multiplier="283:42" id="pOt-gn-Waw"/>
|
||||
<constraint firstAttribute="trailing" secondItem="aDS-iZ-I7j" secondAttribute="trailing" constant="13" id="sLj-wg-x1p"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstItem="RMg-xc-HpK" firstAttribute="height" secondItem="Tzf-9e-1bw" secondAttribute="height" id="4fq-se-8zA"/>
|
||||
<constraint firstItem="zr1-cI-wIv" firstAttribute="leading" secondItem="kzp-eP-IHb" secondAttribute="leading" constant="25" id="5kv-M3-Xip"/>
|
||||
<constraint firstItem="Tzf-9e-1bw" firstAttribute="leading" secondItem="kzp-eP-IHb" secondAttribute="leading" constant="25" id="5zF-eg-zGF"/>
|
||||
<constraint firstAttribute="trailing" secondItem="Tzf-9e-1bw" secondAttribute="trailing" constant="25" id="8tl-BJ-p3C"/>
|
||||
<constraint firstItem="RMg-xc-HpK" firstAttribute="top" secondItem="Tzf-9e-1bw" secondAttribute="top" id="BCS-wj-IZh"/>
|
||||
<constraint firstAttribute="trailing" secondItem="yfz-NH-iVG" secondAttribute="trailing" constant="25" id="Ciy-fX-s37"/>
|
||||
<constraint firstItem="5bx-Ia-Wcm" firstAttribute="top" secondItem="zr1-cI-wIv" secondAttribute="bottom" constant="8" id="GQG-pD-c7r"/>
|
||||
<constraint firstItem="Tzf-9e-1bw" firstAttribute="centerX" secondItem="kzp-eP-IHb" secondAttribute="centerX" id="NQE-l0-XAR"/>
|
||||
<constraint firstItem="RMg-xc-HpK" firstAttribute="leading" secondItem="Tzf-9e-1bw" secondAttribute="trailing" constant="-92" id="NUv-Mb-T9y"/>
|
||||
<constraint firstAttribute="trailing" secondItem="5bx-Ia-Wcm" secondAttribute="trailing" constant="25" id="PGG-t0-R4l"/>
|
||||
<constraint firstItem="RMg-xc-HpK" firstAttribute="bottom" secondItem="Tzf-9e-1bw" secondAttribute="bottom" id="TQq-H0-IgP"/>
|
||||
<constraint firstItem="yfz-NH-iVG" firstAttribute="top" secondItem="Tzf-9e-1bw" secondAttribute="bottom" constant="28" id="XyB-wS-T63"/>
|
||||
<constraint firstItem="zr1-cI-wIv" firstAttribute="top" secondItem="kzp-eP-IHb" secondAttribute="top" constant="21" id="aHb-HI-21u"/>
|
||||
<constraint firstItem="yfz-NH-iVG" firstAttribute="leading" secondItem="kzp-eP-IHb" secondAttribute="leading" constant="25" id="lcm-yf-hbB"/>
|
||||
<constraint firstItem="Tzf-9e-1bw" firstAttribute="top" secondItem="5bx-Ia-Wcm" secondAttribute="bottom" constant="8" symbolic="YES" id="lvb-1r-OR9"/>
|
||||
<constraint firstItem="5bx-Ia-Wcm" firstAttribute="leading" secondItem="kzp-eP-IHb" secondAttribute="leading" constant="25" id="mu3-gc-xGj"/>
|
||||
<constraint firstItem="yfz-NH-iVG" firstAttribute="centerX" secondItem="kzp-eP-IHb" secondAttribute="centerX" id="seX-Im-8qt"/>
|
||||
<constraint firstAttribute="trailing" secondItem="zr1-cI-wIv" secondAttribute="trailing" constant="25" id="suH-kC-9N1"/>
|
||||
<constraint firstAttribute="width" secondItem="kzp-eP-IHb" secondAttribute="height" multiplier="333:224" constant="-74.33035714285711" id="t1U-Wf-oCu"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="kzp-eP-IHb" secondAttribute="trailing" constant="21" id="ON5-f8-sXO"/>
|
||||
<constraint firstItem="kzp-eP-IHb" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="21" id="OdU-BS-jqB"/>
|
||||
<constraint firstItem="kzp-eP-IHb" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" constant="93" id="Y4X-0q-OBR"/>
|
||||
<constraint firstItem="kzp-eP-IHb" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="ii4-8G-vsb"/>
|
||||
</constraints>
|
||||
<point key="canvasLocation" x="-67.5" y="270.5"/>
|
||||
</view>
|
||||
</objects>
|
||||
</document>
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// ChangeModelDoneController.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 15/9/28.
|
||||
// Copyright © 2015年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "BaseVIewContorller.h"
|
||||
|
||||
@interface ChangeModelDoneController : BaseVIewContorller
|
||||
{
|
||||
BOOL _isSetVC;
|
||||
}
|
||||
@property (weak, nonatomic) IBOutlet UITextField *xinModelNumber;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UITextField *yanzhengfeild;
|
||||
|
||||
- (IBAction)doneBtn:(id)sender;
|
||||
@property (weak, nonatomic) IBOutlet UIButton *counttiyCodeBtn;
|
||||
@property (weak, nonatomic) IBOutlet UIView *countryView;
|
||||
|
||||
@end
|
||||
+268
@@ -0,0 +1,268 @@
|
||||
//
|
||||
// ChangeModelDoneController.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 15/9/28.
|
||||
// Copyright © 2015年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ChangeModelDoneController.h"
|
||||
#import "AFNetworking.h"
|
||||
#import "SetViewController.h"
|
||||
#import "MyMD5.h"
|
||||
#import "XWCountryCodeController.h"
|
||||
@interface ChangeModelDoneController ()
|
||||
@property (weak, nonatomic) IBOutlet UIButton *timerbtn;
|
||||
@property (weak, nonatomic) IBOutlet UIButton *wanchengBtn;
|
||||
@property(nonatomic,copy)NSString*verifyData;
|
||||
@property(nonatomic,copy) NSString *areaCode;
|
||||
@end
|
||||
extern BOOL firstLogIn;
|
||||
@implementation ChangeModelDoneController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
[self addTitleViewWithTitle:@"更换手机号"];
|
||||
_timerbtn.backgroundColor=COLOR_LABEL_TITLE;
|
||||
_wanchengBtn.backgroundColor=COLOR_LABEL_TITLE;
|
||||
self.areaCode = @"86";
|
||||
self.view.backgroundColor= [UIColor colorWithPatternImage:[UIImage imageNamed:@"enter_background"]];
|
||||
|
||||
[_timerbtn addTarget:self action:@selector(taptime) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
[self setTextStyle];
|
||||
[self.counttiyCodeBtn addTarget:self action:@selector(countryCodeAction) forControlEvents:UIControlEventTouchUpInside];
|
||||
self.view.backgroundColor = [UIColor whiteColor];
|
||||
}
|
||||
-(void)setTextStyle{
|
||||
self.xinModelNumber.layer.masksToBounds=YES;
|
||||
self.xinModelNumber.layer.cornerRadius=5;
|
||||
self.yanzhengfeild.layer.masksToBounds=YES;
|
||||
self.yanzhengfeild.layer.cornerRadius=5;
|
||||
_timerbtn.layer.masksToBounds=YES;
|
||||
_timerbtn.layer.cornerRadius=5;
|
||||
_wanchengBtn.layer.masksToBounds = YES;
|
||||
_wanchengBtn.layer.cornerRadius = 5;
|
||||
self.countryView.layer.masksToBounds = YES;
|
||||
self.countryView.layer.cornerRadius = 5;
|
||||
|
||||
|
||||
UIView*phoneView=[[UIView alloc]initWithFrame:CGRectMake(0,0, 10, 10)];
|
||||
self.xinModelNumber.leftView=phoneView;
|
||||
self.xinModelNumber.leftViewMode=UITextFieldViewModeAlways;
|
||||
UIView*phoneView1=[[UIView alloc]initWithFrame:CGRectMake(0,0, 10, 10)];
|
||||
self.yanzhengfeild.leftView=phoneView1;
|
||||
self.yanzhengfeild.leftViewMode=UITextFieldViewModeAlways;
|
||||
|
||||
}
|
||||
|
||||
-(void)taptime{
|
||||
|
||||
|
||||
__block int timeout=60; //倒计时时间
|
||||
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
|
||||
dispatch_source_t _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,queue);
|
||||
dispatch_source_set_timer(_timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //每秒执行
|
||||
dispatch_source_set_event_handler(_timer, ^{
|
||||
if(timeout<=0){ //倒计时结束,关闭
|
||||
dispatch_source_cancel(_timer);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
//设置界面的按钮显示 根据自己需求设置
|
||||
[_timerbtn setTitle:@"获取验证码" forState:UIControlStateNormal];
|
||||
_timerbtn.backgroundColor = COLOR_LABEL_TITLE;
|
||||
|
||||
_timerbtn.userInteractionEnabled = YES;
|
||||
});
|
||||
}else{
|
||||
// int minutes = timeout / 60;
|
||||
int seconds = timeout % 60;
|
||||
NSString *strTime=@"";
|
||||
if (seconds==0) {
|
||||
strTime=@"60";
|
||||
}else{
|
||||
strTime = [NSString stringWithFormat:@"%.2d", seconds];
|
||||
}
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
//设置界面的按钮显示 根据自己需求设置
|
||||
NSLog(@"____%@",strTime);
|
||||
[_timerbtn setTitle:[NSString stringWithFormat:@"%@秒",strTime] forState:UIControlStateNormal];
|
||||
_timerbtn.userInteractionEnabled = NO;
|
||||
_timerbtn.backgroundColor=[UIColor lightGrayColor];
|
||||
});
|
||||
timeout--;
|
||||
|
||||
}
|
||||
});
|
||||
dispatch_resume(_timer);
|
||||
|
||||
[self getVerifycode];
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - 获取验证码新(SMS)
|
||||
|
||||
-(void)getVerifycode{
|
||||
|
||||
if ([self.xinModelNumber.text isEqualToString:@""]) {
|
||||
|
||||
[self.view makeToast:@"请输入正确手机号"];
|
||||
return;
|
||||
}
|
||||
|
||||
[IFISHHTTPTOOL getverifyWithTimerButton:_timerbtn addphoneNumber:self.xinModelNumber.text zone:self.areaCode result:^(NSError *err) {
|
||||
|
||||
}];
|
||||
|
||||
}
|
||||
#define mark - 获取阿里验证码 已去
|
||||
|
||||
-(void)getAliVerify:(dispatch_source_t)timer{
|
||||
if ([self.xinModelNumber.text isEqualToString:@""]) {
|
||||
|
||||
[self.view makeToast:@"请输入正确手机号"];
|
||||
return;
|
||||
}
|
||||
AFHTTPRequestOperationManager*mannager=[AFHTTPRequestOperationManager manager];
|
||||
mannager.responseSerializer=[AFHTTPResponseSerializer serializer];
|
||||
|
||||
BOOL isMacth=[dataContorl valiMobile:self.xinModelNumber.text];
|
||||
|
||||
if (isMacth==YES) {
|
||||
|
||||
NSDictionary*dic=@{@"phoneNumber":self.xinModelNumber.text,@"sendType":@"1"};
|
||||
NSLog(@"dic2:%@",dic);
|
||||
|
||||
[AFHttpTool getSecurityCodeWithPhoneNumber:self.xinModelNumber.text sendType:@"1" success:^(id response) {
|
||||
if (response) {
|
||||
NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
||||
|
||||
_verifyData=reDic[@"data"];
|
||||
NSLog(@"_verifyData%@",_verifyData);
|
||||
if ([reDic[@"result"] isEqualToString:@"100"]) {
|
||||
|
||||
[self.view makeToast:@"更换成功"];
|
||||
UserModel*userModel=[[DataCenter defaultDtacenter]valueForKey:@"UserLogIn"];
|
||||
userModel.phoneNumber=self.xinModelNumber.text;
|
||||
|
||||
|
||||
}else if([reDic[@"result"] isEqualToString:@"101"]){
|
||||
dispatch_source_cancel(timer);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
//设置界面的按钮显示 根据自己需求设置
|
||||
[_timerbtn setTitle:@"获取验证码" forState:UIControlStateNormal];
|
||||
_timerbtn.userInteractionEnabled = YES;
|
||||
});
|
||||
|
||||
[self.view makeToast:@"获取验证失败"];
|
||||
// 获取验证失败
|
||||
}else if ([reDic[@"result"] isEqualToString:@"201"]){
|
||||
|
||||
dispatch_source_cancel(timer);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
//设置界面的按钮显示 根据自己需求设置
|
||||
[_timerbtn setTitle:@"获取验证码" forState:UIControlStateNormal];
|
||||
_timerbtn.userInteractionEnabled = YES;
|
||||
});
|
||||
|
||||
[self.view makeToast:@"手机已经注册过"];
|
||||
}else{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} failure:^(NSError *err) {
|
||||
|
||||
UIAlertView *alter =[[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"请检查您的网络" delegate:self cancelButtonTitle:@"取消" otherButtonTitles: nil];
|
||||
[alter show];
|
||||
|
||||
}];
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
[self.view makeToast:@"请输入正确手机号"];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
}
|
||||
#pragma mark-处理收键盘
|
||||
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
|
||||
[textField resignFirstResponder];
|
||||
return YES;
|
||||
|
||||
}
|
||||
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
|
||||
[self hiddenKeybord];
|
||||
|
||||
}
|
||||
-(void)hiddenKeybord{
|
||||
[self.xinModelNumber resignFirstResponder];
|
||||
[self.yanzhengfeild resignFirstResponder];
|
||||
}
|
||||
|
||||
- (IBAction)doneBtn:(id)sender {
|
||||
|
||||
// BOOL isMacth=[dataContorl valiMobile:self.xinModelNumber.text];
|
||||
//
|
||||
// if ((!isMacth)|(self.yanzhengfeild.text.length ==0)){
|
||||
//
|
||||
// [self.view makeToast:@"请输入正确手机号和验证码"];
|
||||
//
|
||||
// return;
|
||||
// }
|
||||
|
||||
[SMSSDK commitVerificationCode:self.yanzhengfeild.text phoneNumber:self.xinModelNumber.text zone:self.areaCode result:^(SMSSDKUserInfo *userInfo, NSError *error) {
|
||||
|
||||
{
|
||||
if (!error)
|
||||
{
|
||||
|
||||
NSLog(@"验证成功");
|
||||
if (firstLogIn) {
|
||||
|
||||
[self.navigationController popToRootViewControllerAnimated:YES];
|
||||
}else{
|
||||
|
||||
//[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:YES];
|
||||
|
||||
[self.navigationController popToRootViewControllerAnimated:YES];
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"错误信息:%@",error);
|
||||
NSString *str =@"验证码验证失败";
|
||||
[self.view makeToast:str];
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(void)countryCodeAction
|
||||
{
|
||||
XWCountryCodeController *CountryCodeVC = [[XWCountryCodeController alloc] init];
|
||||
//CountryCodeVC.deleagete = self;
|
||||
|
||||
[CountryCodeVC toReturnCountryCode:^(NSString *countryCodeStr) {
|
||||
|
||||
[self.counttiyCodeBtn setTitle:countryCodeStr forState:UIControlStateNormal];
|
||||
|
||||
NSArray *array = [countryCodeStr componentsSeparatedByString:@"+"];
|
||||
self.areaCode = array[1];
|
||||
}];
|
||||
[self presentViewController:CountryCodeVC animated:YES completion:nil];
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
|
||||
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ChangeModelDoneController">
|
||||
<connections>
|
||||
<outlet property="countryView" destination="Kvk-oJ-fCT" id="hmW-FT-vtx"/>
|
||||
<outlet property="counttiyCodeBtn" destination="bnp-yg-aVt" id="6z2-JJ-K8v"/>
|
||||
<outlet property="timerbtn" destination="GX9-Vb-Hkq" id="HDE-qF-Uhj"/>
|
||||
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
|
||||
<outlet property="wanchengBtn" destination="Gnx-qr-IDi" id="4lm-Nd-kGK"/>
|
||||
<outlet property="xinModelNumber" destination="QCc-Fe-NNj" id="iE7-WI-Owx"/>
|
||||
<outlet property="yanzhengfeild" destination="viS-cM-hZp" id="bP0-5P-xfo"/>
|
||||
</connections>
|
||||
</placeholder>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="IEY-Ev-2B8">
|
||||
<rect key="frame" x="21" y="93" width="333" height="276.5"/>
|
||||
<subviews>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="请输入新手机号" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="QCc-Fe-NNj">
|
||||
<rect key="frame" x="25" y="64.5" width="283" height="41"/>
|
||||
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" secondItem="QCc-Fe-NNj" secondAttribute="height" multiplier="322:47" id="iyk-OZ-JsL"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="请输入验证码" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="viS-cM-hZp">
|
||||
<rect key="frame" x="25" y="113.5" width="283" height="42"/>
|
||||
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" secondItem="viS-cM-hZp" secondAttribute="height" multiplier="283:42" id="i47-mg-if1"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Gnx-qr-IDi">
|
||||
<rect key="frame" x="25" y="183.5" width="283" height="43"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" secondItem="Gnx-qr-IDi" secondAttribute="height" multiplier="283:43" id="Tbg-qs-nhA"/>
|
||||
</constraints>
|
||||
<state key="normal" title="完成">
|
||||
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="doneBtn:" destination="-1" eventType="touchUpInside" id="hag-mB-PwP"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="GX9-Vb-Hkq">
|
||||
<rect key="frame" x="205" y="64.5" width="103" height="41"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="103" id="EWz-dX-6cN"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<state key="normal" title="获取验证码">
|
||||
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</state>
|
||||
</button>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Kvk-oJ-fCT">
|
||||
<rect key="frame" x="25" y="15" width="283" height="41.5"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="国家/地区" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="cN8-R8-uyP">
|
||||
<rect key="frame" x="10" y="10" width="69" height="21"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="69" id="Ozx-mS-2er"/>
|
||||
<constraint firstAttribute="height" constant="21" id="djd-R9-C59"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="15"/>
|
||||
<color key="textColor" red="0.59999999999999998" green="0.59999999999999998" blue="0.59999999999999998" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="bnp-yg-aVt">
|
||||
<rect key="frame" x="86" y="5.5" width="189" height="30"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="189" id="869-sX-XDA"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="15"/>
|
||||
<state key="normal" title="中国+86">
|
||||
<color key="titleColor" red="0.40000000000000002" green="0.40000000000000002" blue="0.40000000000000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</state>
|
||||
</button>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<constraints>
|
||||
<constraint firstItem="cN8-R8-uyP" firstAttribute="leading" secondItem="Kvk-oJ-fCT" secondAttribute="leading" constant="10" id="MBc-ZL-nLy"/>
|
||||
<constraint firstAttribute="width" secondItem="Kvk-oJ-fCT" secondAttribute="height" multiplier="322:47" id="Xio-KE-RMK"/>
|
||||
<constraint firstItem="bnp-yg-aVt" firstAttribute="centerY" secondItem="Kvk-oJ-fCT" secondAttribute="centerY" id="dol-qO-Gon"/>
|
||||
<constraint firstAttribute="trailing" secondItem="bnp-yg-aVt" secondAttribute="trailing" constant="8" id="jbl-cp-GDY"/>
|
||||
<constraint firstItem="cN8-R8-uyP" firstAttribute="centerY" secondItem="Kvk-oJ-fCT" secondAttribute="centerY" id="vEH-bm-OHa"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstItem="viS-cM-hZp" firstAttribute="centerX" secondItem="IEY-Ev-2B8" secondAttribute="centerX" id="0kh-E2-cD9"/>
|
||||
<constraint firstItem="GX9-Vb-Hkq" firstAttribute="top" secondItem="QCc-Fe-NNj" secondAttribute="top" id="2VD-9L-TUH"/>
|
||||
<constraint firstItem="Gnx-qr-IDi" firstAttribute="leading" secondItem="IEY-Ev-2B8" secondAttribute="leading" constant="25" id="AW7-Yw-dGL"/>
|
||||
<constraint firstItem="QCc-Fe-NNj" firstAttribute="leading" secondItem="IEY-Ev-2B8" secondAttribute="leading" constant="25" id="HDr-hg-Cj4"/>
|
||||
<constraint firstItem="viS-cM-hZp" firstAttribute="leading" secondItem="IEY-Ev-2B8" secondAttribute="leading" constant="25" id="IWh-ts-tlA"/>
|
||||
<constraint firstAttribute="width" secondItem="IEY-Ev-2B8" secondAttribute="height" multiplier="333:226" constant="-73.96460176991144" id="JG8-cZ-Idr"/>
|
||||
<constraint firstItem="GX9-Vb-Hkq" firstAttribute="trailing" secondItem="QCc-Fe-NNj" secondAttribute="trailing" id="Jiq-Iy-naY"/>
|
||||
<constraint firstAttribute="trailing" secondItem="viS-cM-hZp" secondAttribute="trailing" constant="25" id="Q56-Lh-y8M"/>
|
||||
<constraint firstAttribute="trailing" secondItem="QCc-Fe-NNj" secondAttribute="trailing" constant="25" id="Rya-TH-XG1"/>
|
||||
<constraint firstItem="Gnx-qr-IDi" firstAttribute="centerX" secondItem="IEY-Ev-2B8" secondAttribute="centerX" id="Tce-xk-F2d"/>
|
||||
<constraint firstItem="QCc-Fe-NNj" firstAttribute="top" secondItem="Kvk-oJ-fCT" secondAttribute="bottom" constant="8.3333333333333357" id="ThA-nt-zKC"/>
|
||||
<constraint firstItem="Kvk-oJ-fCT" firstAttribute="top" secondItem="IEY-Ev-2B8" secondAttribute="top" constant="15" id="Ttv-I1-FYT"/>
|
||||
<constraint firstAttribute="trailing" secondItem="Kvk-oJ-fCT" secondAttribute="trailing" constant="25" id="n2p-XK-xuO"/>
|
||||
<constraint firstItem="Kvk-oJ-fCT" firstAttribute="leading" secondItem="IEY-Ev-2B8" secondAttribute="leading" constant="25" id="q7i-m5-ZWt"/>
|
||||
<constraint firstAttribute="trailing" secondItem="Gnx-qr-IDi" secondAttribute="trailing" constant="25" id="tUK-xG-Pu2"/>
|
||||
<constraint firstItem="Gnx-qr-IDi" firstAttribute="top" secondItem="viS-cM-hZp" secondAttribute="bottom" constant="28" id="uxZ-m0-GQ7"/>
|
||||
<constraint firstItem="viS-cM-hZp" firstAttribute="top" secondItem="GX9-Vb-Hkq" secondAttribute="bottom" constant="8" symbolic="YES" id="xwH-3X-exY"/>
|
||||
<constraint firstItem="GX9-Vb-Hkq" firstAttribute="bottom" secondItem="QCc-Fe-NNj" secondAttribute="bottom" id="zEf-QM-osw"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<constraints>
|
||||
<constraint firstItem="IEY-Ev-2B8" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="21" id="7QK-n0-9eZ"/>
|
||||
<constraint firstItem="IEY-Ev-2B8" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" constant="93" id="7eI-vq-7Zj"/>
|
||||
<constraint firstItem="IEY-Ev-2B8" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="9XW-rU-26Z"/>
|
||||
<constraint firstAttribute="trailing" secondItem="IEY-Ev-2B8" secondAttribute="trailing" constant="21" id="XdN-ib-GUq"/>
|
||||
</constraints>
|
||||
<point key="canvasLocation" x="495.5" y="327.5"/>
|
||||
</view>
|
||||
</objects>
|
||||
</document>
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// ChangeSecretCodeController.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 15/9/29.
|
||||
// Copyright © 2015年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "BaseVIewContorller.h"
|
||||
|
||||
@interface ChangeSecretCodeController : BaseVIewContorller
|
||||
@property (weak, nonatomic) IBOutlet UITextField *oldSecretCode;
|
||||
@property (weak, nonatomic) IBOutlet UITextField *secretCodeNew;
|
||||
@property (weak, nonatomic) IBOutlet UITextField *repeadNewCode;
|
||||
- (IBAction)finishBtn:(id)sender;
|
||||
|
||||
|
||||
@end
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
//
|
||||
// ChangeSecretCodeController.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 15/9/29.
|
||||
// Copyright © 2015年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ChangeSecretCodeController.h"
|
||||
#import "AFNetworking.h"
|
||||
#import "MyMD5.h"
|
||||
@interface ChangeSecretCodeController ()
|
||||
@property (weak, nonatomic) IBOutlet UIButton *doneButton;
|
||||
|
||||
@end
|
||||
|
||||
@implementation ChangeSecretCodeController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
[self addTitleViewWithTitle:@"修改密码"];
|
||||
[self updatePwd];
|
||||
_doneButton.backgroundColor=COLOR_LABEL_TITLE;
|
||||
self.view.backgroundColor= [UIColor colorWithPatternImage:[UIImage imageNamed:@"enter_background"]];
|
||||
|
||||
[self keyBordType];
|
||||
|
||||
}
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
|
||||
}
|
||||
-(void)updatePwd{
|
||||
}
|
||||
|
||||
#pragma mark-处理收键盘
|
||||
-(void)keyBordType{
|
||||
|
||||
self.secretCodeNew.secureTextEntry=YES;
|
||||
self.repeadNewCode.secureTextEntry=YES;
|
||||
self.oldSecretCode.secureTextEntry=YES;
|
||||
//self.oldSecretCode.layer.borderColor=(__bridge CGColorRef _Nullable)([UIColor orangeColor]);
|
||||
|
||||
self.oldSecretCode.layer.masksToBounds=YES;
|
||||
self.oldSecretCode.layer.cornerRadius=5;
|
||||
self.secretCodeNew.layer.masksToBounds=YES;
|
||||
self.secretCodeNew.layer.cornerRadius=5;
|
||||
self.repeadNewCode.layer.masksToBounds=YES;
|
||||
self.repeadNewCode.layer.cornerRadius=5;
|
||||
self.doneButton.layer.masksToBounds = YES;
|
||||
self.doneButton.layer.cornerRadius = 5;
|
||||
|
||||
|
||||
UIView*phoneView=[[UIView alloc]initWithFrame:CGRectMake(0,0, 10, 10)];
|
||||
self.secretCodeNew.secureTextEntry=YES;
|
||||
self.secretCodeNew.leftView=phoneView;
|
||||
self.secretCodeNew.leftViewMode=UITextFieldViewModeAlways;
|
||||
UIView*phoneView1=[[UIView alloc]initWithFrame:CGRectMake(0,0, 10, 10)];
|
||||
self.repeadNewCode.leftView=phoneView1;
|
||||
self.repeadNewCode.leftViewMode=UITextFieldViewModeAlways;
|
||||
|
||||
UIView*phoneView2=[[UIView alloc]initWithFrame:CGRectMake(0,0, 10, 10)];
|
||||
self.oldSecretCode.leftViewMode=UITextFieldViewModeAlways;
|
||||
self.oldSecretCode.leftView=phoneView2;
|
||||
|
||||
|
||||
|
||||
}
|
||||
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
|
||||
[textField resignFirstResponder];
|
||||
return YES;
|
||||
|
||||
}
|
||||
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
|
||||
[self hiddenKeybord];
|
||||
|
||||
}
|
||||
-(void)hiddenKeybord{
|
||||
[self.oldSecretCode resignFirstResponder];
|
||||
[self.secretCodeNew resignFirstResponder];
|
||||
[self.repeadNewCode resignFirstResponder];
|
||||
|
||||
}
|
||||
- (IBAction)finishBtn:(id)sender {
|
||||
|
||||
|
||||
|
||||
AFHTTPRequestOperationManager*mannager=[AFHTTPRequestOperationManager manager];
|
||||
mannager.responseSerializer=[AFHTTPResponseSerializer serializer];
|
||||
UserModel*userModel=[[DataCenter defaultDtacenter]valueForKey:@"UserLogIn"];
|
||||
NSMutableDictionary*dic=[NSMutableDictionary dictionary];
|
||||
NSString*oldStr=[MyMD5 md5:self.oldSecretCode.text];
|
||||
[dic setValue:oldStr forKey:@"oldPassword"];
|
||||
|
||||
[dic setValue:userModel.userId forKey:@"userId"];
|
||||
NSString*newPass=[MyMD5 md5:self.secretCodeNew.text];
|
||||
[dic setValue:newPass forKey:@"userPassword"];
|
||||
|
||||
[mannager POST:kUpdatePwd parameters:dic success:^(AFHTTPRequestOperation *operation, id responseObject) {
|
||||
if (responseObject) {
|
||||
NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
|
||||
if ([reDic[@"result"] isEqualToString:@"100"]) {
|
||||
[self showTitle:@"" messsage:@"密码修改成功"];
|
||||
NSUserDefaults*userDefsult=[NSUserDefaults standardUserDefaults];
|
||||
[userDefsult setObject:self.secretCodeNew.text forKey:@"password"];
|
||||
|
||||
}else if ([reDic[@"result"] isEqualToString:@"101"]){
|
||||
|
||||
[self showTitle:@"" messsage:@"修改失败"];
|
||||
}else if ([reDic[@"result"] isEqualToString:@"301"]){
|
||||
|
||||
[self showTitle:@"" messsage:@"请求验证失败,请重新登陆"];
|
||||
}else if ([reDic[@"result"] isEqualToString:@"302"]){
|
||||
//[self showTitle:@"" messsage:@"请求被舍弃,未执行"];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
|
||||
|
||||
[self showTitle:@"" messsage:@"网络有问题?"];
|
||||
}];
|
||||
|
||||
}
|
||||
-(void)showTitle:(NSString*)title messsage:(NSString*)message{
|
||||
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:title message:message delegate:nil cancelButtonTitle:nil otherButtonTitles:nil, nil];
|
||||
NSTimeInterval dismissSeconds=1.0;
|
||||
[alert show];
|
||||
[self performSelector:@selector(dismissAlert:) withObject:alert afterDelay:dismissSeconds];
|
||||
|
||||
|
||||
}
|
||||
-(void)dismissAlert:(UIAlertView*)alertView{
|
||||
|
||||
[alertView dismissWithClickedButtonIndex:[alertView cancelButtonIndex] animated:YES];
|
||||
}
|
||||
|
||||
@end
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
|
||||
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ChangeSecretCodeController">
|
||||
<connections>
|
||||
<outlet property="doneButton" destination="xPJ-9q-r9b" id="LqX-nI-YGv"/>
|
||||
<outlet property="oldSecretCode" destination="6oO-Tu-d36" id="aRA-6r-AdF"/>
|
||||
<outlet property="repeadNewCode" destination="oam-h4-t9r" id="fQh-1V-aS5"/>
|
||||
<outlet property="secretCodeNew" destination="P8u-uV-iTb" id="OXG-G1-tue"/>
|
||||
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
|
||||
</connections>
|
||||
</placeholder>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="6kt-a9-XN6">
|
||||
<rect key="frame" x="21" y="93" width="333" height="269.5"/>
|
||||
<subviews>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="请输入原密码" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="6oO-Tu-d36">
|
||||
<rect key="frame" x="25" y="21" width="338" height="42"/>
|
||||
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" secondItem="6oO-Tu-d36" secondAttribute="height" multiplier="283:42" id="EcY-JZ-j1F"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="请设置新密码" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="P8u-uV-iTb">
|
||||
<rect key="frame" x="25" y="71" width="338" height="42"/>
|
||||
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" secondItem="P8u-uV-iTb" secondAttribute="height" multiplier="283:42" id="myc-50-zRy"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="请重复输入新密码" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="oam-h4-t9r">
|
||||
<rect key="frame" x="25" y="121" width="338" height="42"/>
|
||||
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" secondItem="oam-h4-t9r" secondAttribute="height" multiplier="283:42" id="5dp-be-5BA"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="xPJ-9q-r9b">
|
||||
<rect key="frame" x="25" y="191" width="338" height="43"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" secondItem="xPJ-9q-r9b" secondAttribute="height" multiplier="283:43" id="oep-dx-wlV"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<state key="normal" title="修改密码">
|
||||
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="finishBtn:" destination="-1" eventType="touchUpInside" id="QOa-Ar-gSe"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" secondItem="6kt-a9-XN6" secondAttribute="height" multiplier="37:30" id="2Mq-m2-G4H"/>
|
||||
<constraint firstItem="6oO-Tu-d36" firstAttribute="centerX" secondItem="6kt-a9-XN6" secondAttribute="centerX" id="3yc-19-ttn"/>
|
||||
<constraint firstItem="P8u-uV-iTb" firstAttribute="centerX" secondItem="6kt-a9-XN6" secondAttribute="centerX" id="7M2-Fc-lT0"/>
|
||||
<constraint firstItem="oam-h4-t9r" firstAttribute="centerX" secondItem="6kt-a9-XN6" secondAttribute="centerX" id="9gR-Hl-cca"/>
|
||||
<constraint firstItem="xPJ-9q-r9b" firstAttribute="leading" secondItem="6kt-a9-XN6" secondAttribute="leading" constant="25" id="FUE-2W-iB2"/>
|
||||
<constraint firstItem="xPJ-9q-r9b" firstAttribute="top" secondItem="oam-h4-t9r" secondAttribute="bottom" constant="28" id="HTQ-zj-4qH"/>
|
||||
<constraint firstItem="P8u-uV-iTb" firstAttribute="top" secondItem="6oO-Tu-d36" secondAttribute="bottom" constant="8" id="M73-75-ki9"/>
|
||||
<constraint firstAttribute="trailing" secondItem="oam-h4-t9r" secondAttribute="trailing" constant="25" id="O5S-zt-UFB"/>
|
||||
<constraint firstItem="6oO-Tu-d36" firstAttribute="top" secondItem="6kt-a9-XN6" secondAttribute="top" constant="21" id="Rcc-k9-JF0"/>
|
||||
<constraint firstItem="6oO-Tu-d36" firstAttribute="leading" secondItem="6kt-a9-XN6" secondAttribute="leading" constant="25" id="RiG-q3-EvE"/>
|
||||
<constraint firstItem="P8u-uV-iTb" firstAttribute="leading" secondItem="6kt-a9-XN6" secondAttribute="leading" constant="25" id="Vaq-5h-OwS"/>
|
||||
<constraint firstAttribute="trailing" secondItem="P8u-uV-iTb" secondAttribute="trailing" constant="25" id="WHs-8H-5wB"/>
|
||||
<constraint firstAttribute="trailing" secondItem="6oO-Tu-d36" secondAttribute="trailing" constant="25" id="ZPj-El-RMX"/>
|
||||
<constraint firstItem="xPJ-9q-r9b" firstAttribute="centerX" secondItem="6kt-a9-XN6" secondAttribute="centerX" id="eiq-LG-loA"/>
|
||||
<constraint firstAttribute="trailing" secondItem="xPJ-9q-r9b" secondAttribute="trailing" constant="25" id="jAl-PD-oXr"/>
|
||||
<constraint firstItem="oam-h4-t9r" firstAttribute="top" secondItem="P8u-uV-iTb" secondAttribute="bottom" constant="8" id="nVO-uq-B6L"/>
|
||||
<constraint firstItem="oam-h4-t9r" firstAttribute="leading" secondItem="6kt-a9-XN6" secondAttribute="leading" constant="25" id="pdO-r7-iha"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<constraints>
|
||||
<constraint firstItem="6kt-a9-XN6" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="21" id="BGg-ci-avk"/>
|
||||
<constraint firstItem="6kt-a9-XN6" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="Oxp-CD-pCs"/>
|
||||
<constraint firstItem="6kt-a9-XN6" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" constant="93" id="U8T-Gb-jh6"/>
|
||||
<constraint firstAttribute="trailing" secondItem="6kt-a9-XN6" secondAttribute="trailing" constant="21" id="X1S-vF-yff"/>
|
||||
</constraints>
|
||||
<point key="canvasLocation" x="394.5" y="280.5"/>
|
||||
</view>
|
||||
</objects>
|
||||
</document>
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// DownLoadViewController.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 15/12/5.
|
||||
// Copyright © 2015年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "BaseVIewContorller.h"
|
||||
|
||||
@interface DownLoadViewController : BaseVIewContorller
|
||||
@property(nonatomic)BOOL fromsetView;
|
||||
@property(nonatomic,copy)NSString*downAddress;
|
||||
@property(nonatomic)BOOL ismust;
|
||||
@end
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
//
|
||||
// DownLoadViewController.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 15/12/5.
|
||||
// Copyright © 2015年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "DownLoadViewController.h"
|
||||
#import "AppDelegate.h"
|
||||
#import "AFNetworking.h"
|
||||
#import "LeftViewController.h"
|
||||
#import "CenterViewController.h"
|
||||
#import "ICSDrawerController.h"
|
||||
#import "RightViewController.h"
|
||||
|
||||
#import "MyMD5.h"
|
||||
|
||||
//#import <RongIMKit/RongIMKit.h>
|
||||
#import "LogInViewController.h"
|
||||
#define RONYUN_APPKEY @"cpj2xarljddbn"// 融云appkey
|
||||
#import "ChatroomModel.h"
|
||||
#import "AppDelegate.h"
|
||||
@interface DownLoadViewController ()<UIWebViewDelegate>
|
||||
@property(nonatomic,strong)UIWebView*myWebView;
|
||||
@property(nonatomic,strong)UIActivityIndicatorView*indicator;
|
||||
@property(nonatomic,strong)ICSDrawerController*ics;
|
||||
@property(nonatomic,strong)NSMutableArray*deviceArry;
|
||||
@property(nonatomic,strong)NSMutableArray*chatroomArray;
|
||||
@end
|
||||
extern BOOL formLogIn;
|
||||
@implementation DownLoadViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
self.view.backgroundColor=[UIColor whiteColor];
|
||||
[self addTitleViewWithTitle:@"下载页"];
|
||||
[self creatwebView];
|
||||
[self initIndicatorView];
|
||||
self.bakbutton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
self.bakbutton.frame = CGRectMake(0, 0, 60,36);
|
||||
[self.bakbutton setBackgroundImage:[UIImage imageNamed:@"ic_goback"] forState:UIControlStateNormal];
|
||||
[self.bakbutton addTarget: self action: @selector(goBackActionDowlod) forControlEvents: UIControlEventTouchUpInside];
|
||||
if (_ismust==YES) {
|
||||
self.bakbutton.hidden=YES;
|
||||
}else{
|
||||
self.bakbutton.hidden=NO;
|
||||
}
|
||||
self.back=[[UIBarButtonItem alloc]initWithCustomView:self.bakbutton];
|
||||
self.navigationItem.leftBarButtonItem=self.back;
|
||||
_deviceArry=[[NSMutableArray alloc]init];
|
||||
_chatroomArray=[[NSMutableArray alloc]init];
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
}
|
||||
-(void)creatwebView{
|
||||
|
||||
self.myWebView.opaque=NO;
|
||||
self.myWebView.backgroundColor=[UIColor clearColor];
|
||||
self.myWebView=[[UIWebView alloc]initWithFrame:self.view.bounds];
|
||||
NSString*url=self.downAddress;
|
||||
|
||||
NSURLRequest*requst=[NSURLRequest requestWithURL:[NSURL URLWithString:url]];
|
||||
[self.myWebView loadRequest:requst];
|
||||
[self.view addSubview:self.myWebView];
|
||||
self.myWebView.delegate=self;
|
||||
}
|
||||
-(void)webViewDidStartLoad:(UIWebView *)webView{
|
||||
|
||||
[_indicator startAnimating];
|
||||
|
||||
}
|
||||
-(void)webViewDidFinishLoad:(UIWebView *)webView{
|
||||
|
||||
[_indicator stopAnimating];
|
||||
|
||||
}
|
||||
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
|
||||
|
||||
[_indicator stopAnimating];
|
||||
}
|
||||
-(void)initIndicatorView{
|
||||
|
||||
_indicator=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
|
||||
|
||||
CGRectMake(0.f,0.f,40.f, 40.f);
|
||||
_indicator.backgroundColor=[UIColor lightGrayColor];
|
||||
_indicator.center=self.view.center;
|
||||
[self.view addSubview:_indicator];
|
||||
|
||||
}
|
||||
-(void)goBackActionDowlod{
|
||||
if (self.fromsetView==YES) {
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
}else{
|
||||
|
||||
[self dismissViewControllerAnimated:YES completion:^{
|
||||
UIApplication*application=[UIApplication sharedApplication];
|
||||
[self loginAnimated:application];
|
||||
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-(void)loginAnimated:(UIApplication*)appliaction{
|
||||
formLogIn=NO;
|
||||
[IFISHHTTPTOOL ifishLogindismissvc:nil];
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// IfishUDPBroadCastHelper.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/9/12.
|
||||
// Copyright © 2016年 lianxiang. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "AsyncUdpSocket.h"
|
||||
@interface IfishUDPBroadCastHelper : NSObject <AsyncUdpSocketDelegate>
|
||||
|
||||
@property (nonatomic, strong) AsyncUdpSocket *clientSocket;
|
||||
+ (IfishUDPBroadCastHelper *)sharedInstance;
|
||||
@property (nonatomic,strong) NSTimer *loopTimer;
|
||||
|
||||
-(void)broadCaseUDP;
|
||||
|
||||
@end
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
//
|
||||
// IfishUDPBroadCastHelper.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/9/12.
|
||||
// Copyright © 2016年 lianxiang. All rights reserved.
|
||||
//
|
||||
|
||||
#import "IfishUDPBroadCastHelper.h"
|
||||
#import "LxGetCurrentIp.h"
|
||||
#import "AppDelegate.h"
|
||||
@implementation IfishUDPBroadCastHelper
|
||||
|
||||
+ (IfishUDPBroadCastHelper *)sharedInstance{
|
||||
|
||||
static IfishUDPBroadCastHelper *sharedInstace = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
|
||||
sharedInstace = [[self alloc] init];
|
||||
|
||||
|
||||
});
|
||||
|
||||
return sharedInstace;
|
||||
}
|
||||
|
||||
|
||||
-(void)broadCaseUDP{
|
||||
|
||||
self.loopTimer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(sendLoopSoketdata) userInfo:nil repeats:YES];
|
||||
|
||||
}
|
||||
|
||||
|
||||
-(void)sendLoopSoketdata{
|
||||
|
||||
//收9954
|
||||
|
||||
NSString * currentIp = [LxGetCurrentIp currentIPAddress];
|
||||
|
||||
NSArray *array = [currentIp componentsSeparatedByString:@"."];
|
||||
NSMutableArray *mutArr= [NSMutableArray arrayWithArray:array];
|
||||
[mutArr replaceObjectAtIndex:3 withObject:@"255"];
|
||||
NSArray *newarray=mutArr;
|
||||
|
||||
NSString* hostS = [newarray componentsJoinedByString:@"."];
|
||||
|
||||
|
||||
self.clientSocket = [[AsyncUdpSocket alloc] initWithDelegate:self];
|
||||
//120.55.190.56 服务器IP 指令中用
|
||||
NSString *request=@"0007000000000000000000000000273132302e35352e3139302e353600000000000000bbbb0000";
|
||||
|
||||
NSData *data=[dataContorl stringToHexData:request];
|
||||
|
||||
UInt16 port =333;
|
||||
UInt16 bindPort =9954;
|
||||
|
||||
NSError *error;
|
||||
|
||||
[self.clientSocket enableBroadcast:YES error:&error];
|
||||
|
||||
[self.clientSocket sendData:data toHost:hostS port:port withTimeout:-1 tag:1];
|
||||
|
||||
//本地接收端口
|
||||
[self.clientSocket bindToPort:bindPort error:&error];
|
||||
|
||||
[self.clientSocket receiveWithTimeout:-1 tag:0];
|
||||
}
|
||||
|
||||
|
||||
-(BOOL)onUdpSocket:(AsyncUdpSocket *)sock didReceiveData:(NSData *)data withTag:(long)tag fromHost:(NSString *)host port:(UInt16)port
|
||||
{
|
||||
NSString* result;
|
||||
|
||||
result = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
|
||||
|
||||
NSLog(@"didReceiveData%@",result);
|
||||
NSLog(@"port%hu",port);
|
||||
AppDelegate *app =(AppDelegate*)[UIApplication sharedApplication].delegate;
|
||||
[app.window makeToast:@"切换成功"];
|
||||
[self.loopTimer invalidate];
|
||||
|
||||
|
||||
|
||||
return YES;
|
||||
|
||||
}
|
||||
|
||||
-(void)onUdpSocketDidClose:(AsyncUdpSocket *)sock{
|
||||
|
||||
[self.loopTimer invalidate];
|
||||
NSLog(@"关闭");
|
||||
}
|
||||
|
||||
|
||||
-(void)onUdpSocket:(AsyncUdpSocket *)sock didSendDataWithTag:(long)tag{
|
||||
|
||||
NSLog(@"didSendData");
|
||||
|
||||
}
|
||||
|
||||
|
||||
-(void)onUdpSocket:(AsyncUdpSocket *)sock didNotReceiveDataWithTag:(long)tag dueToError:(NSError *)error{
|
||||
|
||||
NSLog(@"dueToError%@",error);
|
||||
[self.loopTimer invalidate];
|
||||
}
|
||||
|
||||
|
||||
-(void)dealloc{
|
||||
|
||||
[self.loopTimer invalidate];
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// LxGetCurrentIp.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/9/12.
|
||||
// Copyright © 2016年 lianxiang. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface LxGetCurrentIp : NSObject
|
||||
|
||||
+(NSString *)currentIPAddress;
|
||||
|
||||
@end
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// LxGetCurrentIp.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/9/12.
|
||||
// Copyright © 2016年 lianxiang. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LxGetCurrentIp.h"
|
||||
#include <ifaddrs.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
@implementation LxGetCurrentIp
|
||||
+(NSString *)currentIPAddress
|
||||
{
|
||||
NSString *address = @"an error occurred when obtaining ip address";
|
||||
struct ifaddrs *interfaces = NULL;
|
||||
struct ifaddrs *temp_addr = NULL;
|
||||
int success = 0;
|
||||
|
||||
success = getifaddrs(&interfaces);
|
||||
if (success == 0) { // 0 表示获取成功
|
||||
|
||||
temp_addr = interfaces;
|
||||
while (temp_addr != NULL) {
|
||||
if( temp_addr->ifa_addr->sa_family == AF_INET) {
|
||||
// Check if interface is en0 which is the wifi connection on the iPhone
|
||||
if ([[NSString stringWithUTF8String:temp_addr->ifa_name] isEqualToString:@"en0"]) {
|
||||
// Get NSString from C String
|
||||
address = [NSString stringWithUTF8String:inet_ntoa(((struct sockaddr_in *)temp_addr->ifa_addr)->sin_addr)];
|
||||
}
|
||||
}
|
||||
|
||||
temp_addr = temp_addr->ifa_next;
|
||||
}
|
||||
}
|
||||
|
||||
freeifaddrs(interfaces);
|
||||
|
||||
NSLog(@"手机的IP是:%@", address);
|
||||
|
||||
return address;
|
||||
|
||||
|
||||
}
|
||||
@end
|
||||
Reference in New Issue
Block a user