// 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
accountField.font = [UIFont systemFontOfSize:15.0f];
accountField.placeholder = @"请输入邮箱";
image = [UIImage imageNamed:@"GlobalInput"];
image = [image stretchableImageWithLeftCapWidth:image.size.width*0.5 topCapHeight:image.size.height*0.5];
[accountField setBackground:image];
[accountField setValue:[NSNumber numberWithInt:10] forKey:@"paddingLeft"];
[self.view addSubview:accountField];就是这样,没有change方法(不过有change方法也是一样往上涨)UITextField定义是在@implementation中定义的。
accountField.font = [UIFont systemFontOfSize:15.0f];
accountField.placeholder = @"请输入邮箱";
image = [UIImage imageNamed:@"GlobalInput"];
image = [image stretchableImageWithLeftCapWidth:image.size.width*0.5 topCapHeight:image.size.height*0.5];
[accountField setBackground:image];
[accountField setValue:[NSNumber numberWithInt:10] forKey:@"paddingLeft"];
[self.view addSubview:accountField];就是这样,没有change方法(不过有change方法也是一样往上涨)UITextField定义是在@implementation中定义的。
把.m中的代码都贴出来
accountField.font = [UIFont systemFontOfSize:15.0f];
accountField.placeholder = @"请输入邮箱";
image = [UIImage imageNamed:@"GlobalInput"];
image = [image stretchableImageWithLeftCapWidth:image.size.width*0.5 topCapHeight:image.size.height*0.5];
[accountField setBackground:image];
[accountField setValue:[NSNumber numberWithInt:10] forKey:@"paddingLeft"];
[self.view addSubview:accountField];就是这样,没有change方法(不过有change方法也是一样往上涨)UITextField定义是在@implementation中定义的。
把.m中的代码都贴出来#import "FYSetAccountViewController.h"
#import "comm/CoreService.h"
#import "Toast+UIView.h"
#import "FYSetPasswordViewController.h"@interface FYSetAccountViewController ()@property (assign,nonatomic) BOOL bCurrPage;@end@implementation FYSetAccountViewController
{
UITextField *accountField;
}- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
-(void)dealloc{
[[NSNotificationCenter defaultCenter] removeObserver:self];
accountField = nil;
}
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:YES];
self.bCurrPage = YES;
}
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:YES];
self.bCurrPage = NO;
}
- (void)viewDidLoad
{
[super viewDidLoad];
UIControl *control = [[UIControl alloc] init];
control.frame = CGRectMake(0, 0, self.width, self.height);
control.backgroundColor = [UIColor clearColor];
[control addTarget:self action:@selector(controlClick) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:control];
UIView *globalTitleBar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.width, 51)];
globalTitleBar.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"GlobalTitle"]];
[self.view addSubview:globalTitleBar];
UIButton *globalBack = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 94, 51)];
[globalBack setBackgroundImage:[UIImage imageNamed:@"GlobalBackNormal"] forState:UIControlStateNormal];
[globalBack setBackgroundImage:[UIImage imageNamed:@"GlobalBackPress"] forState:UIControlStateHighlighted];
[globalBack addTarget:self action:@selector(btnBack) forControlEvents:UIControlEventTouchUpInside];
[globalTitleBar addSubview:globalBack];
UIView *titleView = [[UIView alloc] initWithFrame:CGRectMake(100, 12.5, self.width-200, 25.5)];
[globalTitleBar addSubview:titleView];
UIImageView *globalTitle = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.width-200 ,25.5)];
globalTitle.contentMode = UIViewContentModeScaleAspectFit;
[globalTitle setImage:[UIImage imageNamed:@"SetAccountTxt"]];
[titleView addSubview:globalTitle];
UILabel *stepOne = [[UILabel alloc] initWithFrame:CGRectMake(100, 37, self.width-200, 12)];
stepOne.text = @"(1/2)";
stepOne.textColor = [UIColor whiteColor];
stepOne.font = [UIFont boldSystemFontOfSize:10.0f];
stepOne.textAlignment = NSTextAlignmentCenter;
[globalTitleBar addSubview:stepOne];
UIImage *image;
accountField = [[UITextField alloc] initWithFrame:CGRectMake(12 , 70, 296, 45)];
accountField.font = [UIFont systemFontOfSize:15.0f];
accountField.placeholder = @"请输入邮箱";
image = [UIImage imageNamed:@"GlobalInput"];
image = [image stretchableImageWithLeftCapWidth:image.size.width*0.5 topCapHeight:image.size.height*0.5];
[accountField setBackground:image];
[accountField setValue:[NSNumber numberWithInt:10] forKey:@"paddingLeft"];
[self.view addSubview:accountField];
UILabel *downLevel = [[UILabel alloc] initWithFrame:CGRectMake(14, 121, 292, 40)];
downLevel.textAlignment = NSTextAlignmentLeft;
[downLevel setNumberOfLines:0];
downLevel.font = [UIFont systemFontOfSize:14.0];
downLevel.text = @"请完成账号设置以便您下次登录\n邮箱格式范例:[email protected]";
[self.view addSubview:downLevel];
UIButton *btnNext = [[UIButton alloc] initWithFrame:CGRectMake(12, 167, 296, 41)];
image = [UIImage imageNamed:@"GlobalBlueBtnNormal"];
image = [image stretchableImageWithLeftCapWidth:image.size.width*0.5 topCapHeight:image.size.height*0.5];
[btnNext setBackgroundImage:image forState:UIControlStateNormal];
image = [UIImage imageNamed:@"GlobalBlueBtnPress"];
image = [image stretchableImageWithLeftCapWidth:image.size.width*0.5 topCapHeight:image.size.height*0.5];
[btnNext setBackgroundImage:image forState:UIControlStateHighlighted];
[btnNext setTitle:@"下一步" forState:UIControlStateNormal];
[btnNext setFont:[UIFont boldSystemFontOfSize:20.0f]];
[btnNext addTarget:self action:@selector(btnNext) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btnNext];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(comingSetPassword) name:@"set_account" object:nil];
}-(void)controlClick{
[accountField resignFirstResponder];
}-(void)comingSetPassword{
if( YES == self.bCurrPage ){
NSLog(@"邮箱确认成功");
[self performSelectorOnMainThread:@selector(comingTempPassword) withObject:nil waitUntilDone:NO];
}
}
-(void)comingTempPassword
{
FYSetPasswordViewController *comeSetPassword = [[FYSetPasswordViewController alloc] init];
comeSetPassword.tempAccount = accountField.text;
[self.navigationController pushViewController:comeSetPassword animated:YES];
}
-(void)btnBack
{
[self.navigationController popViewControllerAnimated:YES];
}
-(void)btnNext
{
NSString *accountStr = accountField.text;
Boolean flag = [self validateEmail:accountStr];
if( YES == flag ){
// NSLog(@"格式正确");
ByteBuffer *msg = CoreService::getSharedService()->msgEncoder.setAccountInfo(CoreService::getSharedService()->GetApp().GetAccount().GetUserId(),0,[accountStr UTF8String],[@"" UTF8String]);
CoreService::getSharedService()->SendMsg(msg);
}else{
// NSLog(@"格式错误");
[self.view makeToast:@"您输入的邮箱格式错误。"];
}
[accountField resignFirstResponder];
}//邮箱
- (BOOL) validateEmail:(NSString *)email
{
NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
return [emailTest evaluateWithObject:email];
}- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}/*
#pragma - Navigation
// 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