QQ登陆注册

本文介绍了一个iOS应用中登录界面的具体实现细节,包括自定义视图、按钮操作及简单的验证逻辑。通过触摸开始事件实现了键盘的回收,并且为登录、找回密码和注册功能设置了相应的按钮。
#import "MainViewController.h"
#import "CustomView.h"
#import "PassViewController.h"
#import "RegistViewController.h"
@interface MainViewController ()

@end

@implementation MainViewController
- (void)dealloc
{
    [super dealloc];
}
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    // Do any additional setup after loading the view.
    [self creatView];
    [self CreatButton];
}

- (void)creatView
{

    CustomView *userName = [[CustomView alloc] initWithFrame:CGRectMake(30, 150, 280, 40) text:@"用户名"];
    [self.view addSubview:userName];
    userName.tag = 100;
    userName.leftText.tag = 1000;
    [userName release];

    CustomView *passWord = [[CustomView alloc] initWithFrame:CGRectMake(30, 200, 280, 40) text:@"密码"];
    [self.view addSubview:passWord];
    passWord.tag = 10;
    passWord.leftText.tag = 2000;
    passWord.leftText.secureTextEntry = YES;//密码模式
    [self.view release];


}
// 回收键盘
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    CustomView *pas = (CustomView *)[self.view viewWithTag:10];
    CustomView *name = (CustomView *)[self.view viewWithTag:100];
    [pas.leftText resignFirstResponder];
    [name.leftText resignFirstResponder];
}

- (void)CreatButton
{

    // 登录按钮
    UIButton * loginButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [loginButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    loginButton.frame = CGRectMake(50, 260, 60, 40);
    [loginButton setTitle:@"登录" forState:UIControlStateNormal];
    [loginButton addTarget:self action:@selector(loginButtonCLicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:loginButton];


    // 找回密码按钮
    UIButton * foundButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [foundButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];

    foundButton.frame = CGRectMake(150, 260, 80, 40);
    [foundButton setTitle:@"找回密码" forState:UIControlStateNormal];
    [foundButton addTarget:self action:@selector(foundButtonCLicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:foundButton];


    // 注册按钮
    UIButton * registButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [registButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];

    registButton.frame = CGRectMake(260, 260, 60, 40);
    [registButton setTitle:@"注册" forState:UIControlStateNormal];
    [registButton addTarget:self action:@selector(registButtonCLicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:registButton];



}

- (void)loginButtonCLicked:(id)sender
{
    UITextField * textField = (UITextField *)[self.view viewWithTag:1000];
    UITextField * textField1 = (UITextField *)[self.view viewWithTag:2000];
    if ([textField.text isEqualToString:@""]) {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"傻逼" message:@"用户名不能为空" delegate:nil  cancelButtonTitle:@"返回" otherButtonTitles:nil, nil];
        [alertView show];
        [alertView release];
    }
    else if ([textField.text isEqualToString:@"yu"]) {
        if ([textField1.text isEqualToString:@"123"]) {

            UIAlertView *successView = [[UIAlertView alloc] initWithTitle:@"么么哒" message:@"您登录成功" delegate:self cancelButtonTitle:@"back" otherButtonTitles:nil, nil];
            [successView show];
            [successView release];
        }
        else if(![textField1.text isEqualToString:@"123"] && ![textField1.text isEqualToString:@""])
        {
            UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"(☆_☆)" message:@"你确定密码对么?" delegate:nil  cancelButtonTitle:@"返回" otherButtonTitles:nil, nil];
            [alertView show];
            [alertView release];
        }

    }
    if([textField1.text isEqualToString:@""]){
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"(☆_☆)" message:@"请输入密码!!!" delegate:nil  cancelButtonTitle:@"返回" otherButtonTitles:nil, nil];
        [alertView show];
        [alertView release];
    }
    else if(![textField.text isEqualToString:@"yu"] && ![textField.text isEqualToString:@""] && ![textField1.text isEqualToString:@""])
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"您输入的用户不存在" delegate:nil  cancelButtonTitle:@"返回" otherButtonTitles:nil, nil];
        [alertView show];
        [alertView release];
    }

}

// 找回按钮action
- (void)foundButtonCLicked:(id)sender
{
    PassViewController *passVC = [[PassViewController alloc] init];
    [self presentViewController:passVC animated:YES completion:^{

    }];
    [passVC release];
}

// 注册按钮action
- (void)registButtonCLicked:(id)sender
{
    RegistViewController *registVC = [[RegistViewController alloc] init];

    [self presentViewController:registVC animated:YES completion:^{

    }];
    [registVC release];
}

## import "RegistViewController.h 页面##
#import "RegistViewController.h"
#import "CustomView.h"
@interface RegistViewController ()

@end

@implementation RegistViewController
- (void)dealloc
{
    [super dealloc];
}
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    // Do any additional setup after loading the view.
    [self CreateView];
    [self creatButton];
}

-(void)CreateView
{
    NSArray *aArray = [NSArray arrayWithObjects:@"用户名", @"密码", @"确认密码", @"手机", @"邮箱", nil];
    NSArray *bArray = [NSArray arrayWithObjects:@"请输入用户名", @"请输入密码", @"请再次输入", @"请输入手机号", @"请输入邮箱", nil];
    int b = 1;
    for (int i = 0; i < [bArray count]; i++) {
        NSString *str = [aArray objectAtIndex:i];
        CustomView *cus = [[CustomView alloc] initWithFrame:CGRectMake(20, 100 + i * 70, 300, 40) text:str];
        cus.leftText.placeholder = [bArray objectAtIndex:i];
        cus.leftText.tag = b++;
        [self.view addSubview:cus];
        [cus release];
    }
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    for (int i = 1; i < 6; i++) {
        UITextField * field = (UITextField *)[self.view viewWithTag:i];
        [field resignFirstResponder];
    }
}
- (void)creatButton
{

    UIButton * loginButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [loginButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    loginButton.frame = CGRectMake(80, 480, 60, 40);
    [loginButton setTitle:@"注册" forState:UIControlStateNormal];
    [loginButton addTarget:self action:@selector(foundButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:loginButton];


    UIButton * cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [cancelButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    cancelButton.frame = CGRectMake(260, 480, 60, 40);
    [cancelButton setTitle:@"取消" forState:UIControlStateNormal];
    [cancelButton addTarget:self action:@selector(cancelButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:cancelButton];
}

- (void)foundButtonAction:(id)sender
{

}
- (void)cancelButtonAction:(id)sender
{
    [self dismissViewControllerAnimated:YES completion:^{

    }];
}
## import "PassViewController.h 页面##
#import "PassViewController.h"
#import "CustomView.h"
@interface PassViewController ()

@end

@implementation PassViewController
- (void)dealloc
{
    [super dealloc];
}
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    // Do any additional setup after loading the view.
    [self creatView];
}
- (void)creatView
{
    UITextField * mail = [[UITextField alloc] initWithFrame:CGRectMake(30, 100, 300, 40)];
    mail.placeholder = @"电子邮箱";
    mail.borderStyle = UITextBorderStyleRoundedRect;
    mail.keyboardType = UIKeyboardTypeEmailAddress;
    mail.clearsOnBeginEditing = YES;
    mail.tag = 123;
    [self.view addSubview:mail];
    [mail release];


    UIButton * foundButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [foundButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    foundButton.frame = CGRectMake(80, 160, 60, 40);
    [foundButton setTitle:@"找回" forState:UIControlStateNormal];
    [foundButton addTarget:self action:@selector(foundButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:foundButton];




    UIButton * cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [cancelButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    cancelButton.frame = CGRectMake(260, 160, 60, 40);
    [cancelButton setTitle:@"取消" forState:UIControlStateNormal];
    [cancelButton addTarget:self action:@selector(cancelButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:cancelButton];

}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITextField *mail = (UITextField *)[self.view viewWithTag:123];

    [mail resignFirstResponder];
}

- (void)foundButtonAction:(id)sender
{
    [self dismissViewControllerAnimated:YES completion:^{

    }];


}
- (void)cancelButtonAction:(id)sender
{
    [self dismissViewControllerAnimated:YES completion:^{

    }];
}
## 标题 ##
#import <UIKit/UIKit.h>

@interface CustomView : UIView<UITextFieldDelegate>
@property (nonatomic, retain)UILabel *rightLable;
@property (nonatomic, retain)UITextField * leftText;
-(instancetype)initWithFrame:(CGRect)frame text:(NSString *)str;
@end
## 标题 ##
#import "CustomView.h"

@implementation CustomView
- (void)dealloc
{
    [super dealloc];
    [_leftText release];
    [_rightLable release];
}
- (instancetype)initWithFrame:(CGRect)frame text:(NSString *)str
{
    self = [super initWithFrame:frame];
    if (self) {
        self.rightLable = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width / 3 - 10, self.frame.size.height)];
        _rightLable.textAlignment = NSTextAlignmentLeft;
        _rightLable.text = str;
        _rightLable.font = [UIFont boldSystemFontOfSize:20];
        [self addSubview:_rightLable];
        [_rightLable release];

        self.leftText = [[UITextField alloc] initWithFrame:CGRectMake(self.frame.size.width / 3 + 20, 0, self.frame.size.width * 2 / 3 + 10, self.frame.size.height)];
        _leftText.font = [UIFont systemFontOfSize:20];
        _leftText.clearsOnBeginEditing = YES;
        _leftText.borderStyle = UITextBorderStyleRoundedRect;
        [self addSubview:_leftText];
        [_leftText release];

    }
    return self;
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}
考虑可再生能源出力不确定性的商业园区用户需求响应策略(Matlab代码实现)内容概要:本文围绕“考虑可再生能源出力不确定性的商业园区用户需求响应策略”展开,结合Matlab代码实现,研究在可再生能源(如风电、光伏)出力具有不确定性的背景下,商业园区如何制定有效的需求响应策略以优化能源调度和提升系统经济性。文中可能涉及不确定性建模(如场景生成与缩减)、优化模型构建(如随机规划、鲁棒优化)以及需求响应机制设计(如价格型、激励型),并通过Matlab仿真验证所提策略的有效性。此外,文档还列举了大量相关的电力系统、综合能源系统优化调度案例与代码资源,涵盖微电网调度、储能配置、负荷预测等多个方向,形成一个完整的科研支持体系。; 适合人群:具备一定电力系统、优化理论和Matlab编程基础的研究生、科研人员及从事能源系统规划与运行的工程技术人员。; 使用场景及目标:①学习如何建模可再生能源的不确定性并应用于需求响应优化;②掌握使用Matlab进行商业园区能源系统仿真与优化调度的方法;③复现论文结果或开展相关课题研究,提升科研效率与创新能力。; 阅读建议:建议结合文中提供的Matlab代码实例,逐步理解模型构建与求解过程,重点关注不确定性处理方法与需求响应机制的设计逻辑,同时可参考文档中列出的其他资源进行扩展学习与交叉验证。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值