最简单的dome,PHP注册登录系统
iOS 寻觅框控件 最简便易行的dome
刚上学寻觅框控件,写了个最简便易行的dome
#import
.h
@interface ViewController : UIViewController
@property (nonatomic,strong) UISearchDisplayController *searchDisplayC;//搜索框控件控制器
@property (weak, nonatomic) IBOutlet UISearchBar *searchBar;//搜索条
@property (nonatomic,strong) NSArray *allArray;//所有数据数组
@property (nonatomic,strong) NSMutableArray *filterArray;//搜索出来的数据数组
@end
.m
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize searchBar;
@synthesize searchDisplayC;
@synthesize filterArray;
@synthesize allArray;
- (void)viewDidLoad
{
[super viewDidLoad];
allArray = [NSArray arrayWithObjects:@"济南",@"天津",@"潍坊",@"上海",@"北京",@"青岛",@"台湾",@"钓鱼岛", nil];
searchDisplayC = [[UISearchDisplayController alloc]initWithSearchBar:searchBar contentsController:self];
searchDisplayC.delegate = self;
searchDisplayC.searchResultsDelegate = self;
searchDisplayC.searchResultsDataSource = self;
// Do any additional setup after loading the view, typically from a nib.
}
#pragma mark - tabledelegete
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return filterArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *identifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
}
cell.textLabel.text = [filterArray objectAtIndex:indexPath.row];
[cell setAccessoryType:UITableViewCellAccessoryDetailDisclosureButton];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//选择后要做的事情
NSLog(@"已选择");
}
#pragma mark - searchdelegate
- (BOOL) searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
[filterArray removeAllObjects];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF contains[c] %@",searchString];//用于过滤
filterArray = [NSMutableArray arrayWithArray:[allArray filteredArrayUsingPredicate:predicate]];
return YES;
}
- (BOOL) searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchScope:(NSInteger)searchOption
{
//当scope改变时调用
return YES;
}
@end
寻觅框控件 最简便易行的dome 刚学习搜索框控件,写了个最轻便易行的dome #import .h @interface ViewController : UIViewController @property (nonatomic,strong) UISea...
跟着上篇《iOS PHP注册登陆体系PHP部分(上)》张开课习
热修复和热更新
3.iOS部分
1 热翻新和热修复:在线修复程序的 BUG
上三次我们写完了数据库有的和PHP部分本次我们来落成iOS部分。
第风姿浪漫先在storyboard中蓬蓬勃勃阵狂拖,弄成如下图。
能够先在text Field中输入顾客名和密码 方便现在调节和测验。
2 JSPach 的使用原理: OC 是一门动态运转时的言语,方法的运维和指标的创始是在运作时中开创的.JSPatch 正的用运转时,通过JavaScriptCore.framework作为 JS引擎,从 JS 动态调用方法和对象到OC 中,再效用NSInvocation动态调用对应的方法.例
Class class = NSClassFromString(@"UIViewController");
3.1签到部分代码
id controller = [class new];
创造三个新的UIViewController
名称叫registViewController(用于注册客商,ViewController用于登陆)。
在ViewController.h中importregistViewController
#import "registViewController.h"
SEL selector = NSSelectorFromString(@"viewDidLoad");
下一场设置登陆分界面中的控件
用来写客商名的控件名设置为txtUser,密码的控件名设置为txtPwd,分明开关的办法名字为
LoginClick,注册按键的法门名称为registButton。
然后最早写ViewController.m中的代码
[controller performSelector:selector];
//
// ViewController.m
// iosLogin
//
// Created by 曹晗 on 16/2/25.
// Copyright :emoji: 2016年 CaoHan. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UITextField *txtUser;
@property (weak, nonatomic) IBOutlet UITextField *txtPwd;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)LoginClick:(id)sender {
//前后去空格
NSString *userName = [_txtUser.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSString *userPwd = [_txtPwd.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSDictionary *jsonDic = [self getJsonData:userName userpwd:userPwd];
NSString* loginFlag = [jsonDic objectForKey:@"loginFlag"];
NSLog(@"%@",loginFlag);
[self aletrInfo:loginFlag];
}
- (IBAction)registButton:(id)sender {
UIStoryboard *storboard = self.storyboard;
registViewController *vc2 = [storboard instantiateViewControllerWithIdentifier:@"vc2"];
[self presentViewController:vc2 animated:YES completion:nil];
}
//用于请求PHP 获得JSON
- (NSDictionary *)getJsonData:(NSString *)user_name userpwd:(NSString *)user_pwd {
NSError *error;
NSString *urlString = [NSString stringWithFormat:@"http://192.168.1.106/iosLogin/index.php?action=login&user_name=%@&user_pwd=%@",user_name,user_pwd];
//加载一个NSURL对象
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString]];
//将请求的url数据放到NSData对象中
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
//IOS5自带解析类NSJSONSerialization从response中解析出数据放到字典中
NSDictionary *jsonDic = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&error];
NSLog(@"接收到的数据为%@",jsonDic);
returnjsonDic;
}
//弹出信息
- (void)aletrInfo:(NSString *)loginFlag{
UIAlertView *alert = [[UIAlertView alloc]init];
[alert setTitle:@"提示"]; [alert setDelegate:nil];
[alert addButtonWithTitle:@"确定"];
if([loginFlag isEqual: @"0"]) {
[alert setMessage:@"账号或密码错误"];
}
if([loginFlag isEqual:@"1"]) {
[alert setMessage:@"登陆成功"];
}
[alert show];
}
@end
|
3 使用手续
在登记开关能够跳转界前边,要先将stroyboard中的注册分界面包车型地铁stroyboard ID设置为vc2才足以张开跳转。
把JSPatch这一个文件夹拖入到文件中然后就要 gitHub 下载的dome.js文件拖入到花色中,在 APPDelegate中:
#import "AppDelegate.h"
复制代码代码如下:
#import "JPEngine.h"
NSString *urlString = [NSString stringWithFormat:@"];
#import "ViewController.h"
当中这里的192.168.1.106得以写localhost也可以写本人的ip地址。
写到这里就足以先举办调整一下记名了。后边的挂号顾客代码也和这里大概。
@interface AppDelegate ()
3.2挂号分界面代码
先在registViewCongroller.h中import ViewController.h
#import "ViewController.h"
下一场是registViewController.m中的代码。
//
// registViewController.m
// iosLogin
//
// Created by 曹晗 on 16/2/27.
// Copyright 2016年 CaoHan. All rights reserved.
//
#import "registViewController.h"
@interface registViewController ()
@property (weak, nonatomic) IBOutlet UITextField *txtUser;
@property (weak, nonatomic) IBOutlet UITextField *txtPwd;
@end
@implementation registViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
//这个是注册按钮
- (IBAction)registButton:(id)sender {
NSString *userName = [_txtUser.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSString *userPwd = [_txtPwd.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSDictionary *jsonDic = [self getJsonData:userName userpwd:userPwd];
NSString* registFlag = [jsonDic objectForKey:@"registFlag"];
NSLog(@"%@",registFlag);
[self aletrInfo:registFlag];
}
//这个是返回按钮
- (IBAction)returnButton:(id)sender {
[self dismissModalViewControllerAnimated:YES];
}
- (NSDictionary *)getJsonData:(NSString *)user_name userpwd:(NSString *)user_pwd {
NSError *error;
NSString *urlString = [NSString stringWithFormat:@"http://192.168.1.106/iosLogin/index.php?action=regist&user_name=%@&user_pwd=%@",user_name,user_pwd];
//加载一个NSURL对象
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString]];
//将请求的url数据放到NSData对象中
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
//IOS5自带解析类NSJSONSerialization从response中解析出数据放到字典中
NSDictionary *jsonDic = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&error];
NSLog(@"接收到的数据为%@",jsonDic);
returnjsonDic;
}
- (void)aletrInfo:(NSString *)registFlag{
UIAlertView *alert = [[UIAlertView alloc]init];
[alert setTitle:@"提示"]; [alert setDelegate:nil];
[alert addButtonWithTitle:@"确定"];
if([registFlag isEqual: @"0"]) {
[alert setMessage:@"用户名已存在"];
}
if([registFlag isEqual:@"1"]) {
[alert setMessage:@"注册成功"];
}
[alert show];
}
@end
|
@end
@implementation AppDelegate
本文由澳门威利斯人发布于网络资讯,转载请注明出处:最简单的dome,PHP注册登录系统