zoukankan      html  css  js  c++  java
  • 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];
        
        
      
    }
  • 相关阅读:
    [UVA1149]Dominating Patterns
    [HDOJ1358]Period
    [HDOJ3065]病毒侵袭持续中
    【RQNOJ356】myt的格斗
    【rqnoj39】 饮食问题
    【rqnoj28】[Stupid]愚蠢的宠物
    【rqnoj378】 约会计划
    layer弹框在实际项目中的一些应用
    layer弹框在实际项目中的一些应用
    移动开发之css3实现背景几种渐变效果
  • 原文地址:https://www.cnblogs.com/zhangqing979797/p/13715436.html
Copyright © 2011-2022 走看看