• UISB XIB登陆例子


    VCRoot.h

    #import <UIKit/UIKit.h>
    
    NS_ASSUME_NONNULL_BEGIN
    
    @interface VCRoot : UIViewController
    //XIB创建UILabel属性
    
    //IBOutlet属性是在XIB中创建的
    @property (weak, nonatomic) IBOutlet UILabel *mUserName;
    
    //密码属性
    @property (weak, nonatomic) IBOutlet UILabel *mUserPassword;
    
    //输入对话框属性
    @property (weak, nonatomic) IBOutlet UITextField *mTFUserName;
    
    @property (weak, nonatomic) IBOutlet UITextField *mTFPassword;
    
    //按钮
    @property (weak, nonatomic) IBOutlet UIButton *mBTLogin;
    
    @property (weak, nonatomic) IBOutlet UIButton *mBTRegister;
    
    //按钮函数事件同步
    - (IBAction)pressLogin:(UIButton *)sender;
    
    - (IBAction)pressRegister:(id)sender;
    
    
    
    @end

    Root.m

    - (IBAction)pressRegister:(id)sender {
        NSString* uName = @"michael";
        NSString* uPass=@"123456";
        if([_mTFUserName.text isEqual:uName] && [_mTFPassword.text isEqual:uPass]){
            NSLog(@"登录成功");
            
        }else
        {
            
            NSLog(@"登陆失败");
            
        }
        
        
        
        
    }
    
    - (IBAction)pressLogin:(UIButton *)sender {
    }
    
    -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
    {
        [_mTFUserName resignFirstResponder];
        [_mTFPassword resignFirstResponder];
        
    }

    sceneDelegate.m

    #import "SceneDelegate.h"
    #import "VCRoot.h"
    @interface SceneDelegate ()
    
    @end
    
    @implementation SceneDelegate
    
    
    - (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
        self.window = [[UIWindow alloc] initWithWindowScene:(UIWindowScene *)scene];
        self.window.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
        
        VCRoot* root=[[VCRoot alloc]init];
        
        //对窗口的根视图控制器进行赋值操作 属于windows属性
        //整个UIKit框架中只有一个根视图控制器 属于windows的属性
        //视图控制器用来管理界面和处理界面逻辑类对象
    
        //程序启动前必须对根视图控制器赋值
        
        self.window.rootViewController=root;
        
        //将windos作为主视图并且显示出来
        [self.window makeKeyAndVisible];
        
        
      
    }
  • 相关阅读:
    POJ 2987:Firing(最大权闭合图)
    BZOJ 1001:[BeiJing2006]狼抓兔子(最小割)
    HDU 1007:Quoit Design(分治求最近点对)
    POJ 1986:Distance Queries(倍增求LCA)
    HDU 3879 && BZOJ 1497:Base Station && 最大获利 (最大权闭合图)
    BZOJ-1011 遥远的行星
    BZOJ-1044 木棍分割
    BZOJ-1042 硬币购物
    BZOJ-1050 旅行
    BZOJ-1037 生日聚会
  • 原文地址:https://www.cnblogs.com/zhangqing979797/p/13715436.html
Copyright © 2020-2023  润新知