Snail—UI学习之初识

2024-05-05 04:32
文章标签 初识 学习 ui snail

本文主要是介绍Snail—UI学习之初识,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

在AppDelegate.m中有几个默认存在的函数

//
//  WJJAppDelegate.m
//  课上练习
//
//  Created by Snail on 15-7-20.
//  Copyright (c) 2015年 Snail. All rights reserved.
//#import "WJJAppDelegate.h"@implementation WJJAppDelegate//程序的入口 只允许一次
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{   
// [[UIScreen mainScreen] bounds]];    适应当前屏幕的大小
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];// Override point for customization after application launch.
//设置window的背景颜色为白色
self.window.backgroundColor = [UIColor whiteColor];//让window执行显示
[self.window makeKeyAndVisible];return YES;
}//挂起程序
- (void)applicationWillResignActive:(UIApplication *)application
{// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}//程序进入后台
- (void)applicationDidEnterBackground:(UIApplication *)application
{// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}//程序将要进入前台
- (void)applicationWillEnterForeground:(UIApplication *)application
{// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}//当前APP已经能够看到界面  进入前台
- (void)applicationDidBecomeActive:(UIApplication *)application
{// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}- (void)applicationWillTerminate:(UIApplication *)application
{// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}@end

这样我们知道了程序的入口,但是在以后的开发过程中,我们不会直接在AppDelegate.m中写很多的类,而是新建一个UIViewController,把自己创建的一个UIViewController赋值给我们此程序的根视图控制器

接下来,COMMAND+N 新建一个类WJJRootUIViewController 继承于UIViewController

引入头文件后,在下面这个方法这样写

#import "WJJAppDelegate.h"
#import "WJJRootViewController.h"@implementation WJJAppDelegate- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{//当前的window 开辟内存 并用frame初始化//[[UIScreen mainScreen] bounds]] 适应当前屏幕大小self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];self.window.rootViewController = [[WJJRootViewController alloc] init];//设置当前window 的背景色self.window.backgroundColor = [UIColor cyanColor];//让这个windo执行[self.window makeKeyAndVisible];return YES;
}

这样的话,我们的根视图控制器变成了WJJRootUIVIewController

其他不动,我们直接到WJJRootUIViewController.m文件中

#import "WJJRootViewController.h"@interface WJJRootViewController ()@end@implementation WJJRootViewController- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];if (self) {// Custom initialization}return self;
}//此视图控制器的入口 入口只执行一次 其他的进入后台、进入前台等等是在调用下面四个周期函数
- (void)viewDidLoad
{[super viewDidLoad];// Do any additional setup after loading the view.//把背景颜色设置为红色self.view.backgroundColor = [UIColor redColor];
}//视图已经出现
- (void)viewDidAppear:(BOOL)animated{[super viewDidAppear:animated];
}//视图将要出现
- (void)viewWillAppear:(BOOL)animated{[super viewWillAppear:animated];
}//视图将要消失
- (void)viewWillDisappear:(BOOL)animated{[super viewWillDisappear:animated];
}//视图已经消失
- (void)viewDidDisappear:(BOOL)animated{[super viewDidDisappear:animated];
}
- (void)didReceiveMemoryWarning
{[super didReceiveMemoryWarning];// Dispose of any resources that can be recreated.
}@end


这篇关于Snail—UI学习之初识的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/960806

相关文章

Go学习记录之runtime包深入解析

《Go学习记录之runtime包深入解析》Go语言runtime包管理运行时环境,涵盖goroutine调度、内存分配、垃圾回收、类型信息等核心功能,:本文主要介绍Go学习记录之runtime包的... 目录前言:一、runtime包内容学习1、作用:① Goroutine和并发控制:② 垃圾回收:③ 栈和

Android学习总结之Java和kotlin区别超详细分析

《Android学习总结之Java和kotlin区别超详细分析》Java和Kotlin都是用于Android开发的编程语言,它们各自具有独特的特点和优势,:本文主要介绍Android学习总结之Ja... 目录一、空安全机制真题 1:Kotlin 如何解决 Java 的 NullPointerExceptio

VS配置好Qt环境之后但无法打开ui界面的问题解决

《VS配置好Qt环境之后但无法打开ui界面的问题解决》本文主要介绍了VS配置好Qt环境之后但无法打开ui界面的问题解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要... 目UKeLvb录找到Qt安装目录中designer.UKeLvBexe的路径找到vs中的解决方案资源

QT6中绘制UI的两种方法详解与示例代码

《QT6中绘制UI的两种方法详解与示例代码》Qt6提供了两种主要的UI绘制技术:​​QML(QtMeta-ObjectLanguage)​​和​​C++Widgets​​,这两种技术各有优势,适用于不... 目录一、QML 技术详解1.1 QML 简介1.2 QML 的核心概念1.3 QML 示例:简单按钮

重新对Java的类加载器的学习方式

《重新对Java的类加载器的学习方式》:本文主要介绍重新对Java的类加载器的学习方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1、介绍1.1、简介1.2、符号引用和直接引用1、符号引用2、直接引用3、符号转直接的过程2、加载流程3、类加载的分类3.1、显示

在 PyQt 加载 UI 三种常见方法

《在PyQt加载UI三种常见方法》在PyQt中,加载UI文件通常指的是使用QtDesigner设计的.ui文件,并将其转换为Python代码,以便在PyQt应用程序中使用,这篇文章给大家介绍在... 目录方法一:使用 uic 模块动态加载 (不推荐用于大型项目)方法二:将 UI 文件编译为 python 模

Java学习手册之Filter和Listener使用方法

《Java学习手册之Filter和Listener使用方法》:本文主要介绍Java学习手册之Filter和Listener使用方法的相关资料,Filter是一种拦截器,可以在请求到达Servl... 目录一、Filter(过滤器)1. Filter 的工作原理2. Filter 的配置与使用二、Listen

Java进阶学习之如何开启远程调式

《Java进阶学习之如何开启远程调式》Java开发中的远程调试是一项至关重要的技能,特别是在处理生产环境的问题或者协作开发时,:本文主要介绍Java进阶学习之如何开启远程调式的相关资料,需要的朋友... 目录概述Java远程调试的开启与底层原理开启Java远程调试底层原理JVM参数总结&nbsMbKKXJx

Java深度学习库DJL实现Python的NumPy方式

《Java深度学习库DJL实现Python的NumPy方式》本文介绍了DJL库的背景和基本功能,包括NDArray的创建、数学运算、数据获取和设置等,同时,还展示了如何使用NDArray进行数据预处理... 目录1 NDArray 的背景介绍1.1 架构2 JavaDJL使用2.1 安装DJL2.2 基本操

Vue项目中Element UI组件未注册的问题原因及解决方法

《Vue项目中ElementUI组件未注册的问题原因及解决方法》在Vue项目中使用ElementUI组件库时,开发者可能会遇到一些常见问题,例如组件未正确注册导致的警告或错误,本文将详细探讨这些问题... 目录引言一、问题背景1.1 错误信息分析1.2 问题原因二、解决方法2.1 全局引入 Element