iOS UI03_LTView
//
// LTView.h
// OC03_LTView
//
// Created by dllo on 15/7/31.
// Copyright (c) 2015年 dllo. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface LTView :
UIView<UITextFieldDelegate>
// 由于要在类的外部获取输入框的内容,
改动label的标题,
所以我们能够把这两部分作为属性写在.h, 这样在外部能够直接改动和设置
@property(nonatomic,
retain)UILabel *myLabel;
@property(nonatomic,
retain)UITextField *myTwxtField;
@end
//
// LTView.m
// OC03_LTView
//
// Created by dllo on 15/7/31.
// Copyright (c) 2015年 dllo. All rights reserved.
//
#import "LTView.h"
@implementation LTView
// 重写init方法
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super
initWithFrame:frame];
if (self) {
// 模块化
[self
createView];
}
return
self;
}
- (void)createView
{
//
创建两个视图, 一个是label,
一个是textfield
self.myLabel = [[UILabel
alloc] initWithFrame:CGRectMake(20, 20, 100, 30)];
self.myLabel.backgroundColor = [UIColor
yellowColor];
[self
addSubview:self.myLabel];
[_myLabel
release];
self.myTwxtField = [[UITextField
alloc] initWithFrame:CGRectMake(150, 20, 100, 40)];
self.myTwxtField.backgroundColor = [UIColor
cyanColor];
[self
addSubview:self.myTwxtField];
//
设置代理人
self.myTwxtField.delegate =
self;
[_myTwxtField
release];
}
- (void)dealloc
{
[_myTwxtField
release];
[_myLabel
release];
[super
dealloc];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return
YES;
}
@end
//
// AppDelegate.m
// OC03_LTView
//
// Created by dllo on 15/7/31.
// Copyright (c) 2015年 dllo. All rights reserved.
//
#import "AppDelegate.h"
#import "LTView.h"
@interface
AppDelegate ()<UIAlertViewDelegate>
@property(nonatomic,
retain)UIAlertView *alertView;
@end
@implementation AppDelegate
- (void)dealloc
{
[_window
release];
[super
dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions {
self.window = [[UIWindow
alloc] initWithFrame:[[UIScreen
mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor
whiteColor];
[self.window
makeKeyAndVisible];
[_window
release];
//弹出窗体
self.alertView = [[UIAlertView
alloc] initWithTitle:@"測试一下"
message:@"看看效果"
delegate:self
cancelButtonTitle:@"取消"
otherButtonTitles:@"确认",
nil];
[self.alertView
show];
//
让alertview中出现textfield
self.alertView.alertViewStyle =
UIAlertViewStyleLoginAndPasswordInput;
//建立一个LTView视图
LTView *view = [[LTView
alloc] initWithFrame:CGRectMake(0, 0,
self.window.frame.size.width,
self.window.frame.size.height)];
[self.window
addSubview:view];
[view
release];
//显示的内容
view.myLabel.text =
@"账号:";
return
YES;
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSLog(@"11");
//
先找到alertview中的textfield
UITextField *first = [self.alertView
textFieldAtIndex:0];
NSLog(@"%@", first.text);
}
- (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.
}
- (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
iOS UI03_LTView的更多相关文章
- iOS可视化动态绘制连通图
上篇博客<iOS可视化动态绘制八种排序过程>可视化了一下一些排序的过程,本篇博客就来聊聊图的东西.在之前的博客中详细的讲过图的相关内容,比如<图的物理存储结构与深搜.广搜>.当 ...
- 【疯狂造轮子-iOS】JSON转Model系列之二
[疯狂造轮子-iOS]JSON转Model系列之二 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 上一篇<[疯狂造轮子-iOS]JSON转Model系列之一> ...
- 【疯狂造轮子-iOS】JSON转Model系列之一
[疯狂造轮子-iOS]JSON转Model系列之一 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 之前一直看别人的源码,虽然对自己提升比较大,但毕竟不是自己写的,很容易遗 ...
- iOS总结_UI层自我复习总结
UI层复习笔记 在main文件中,UIApplicationMain函数一共做了三件事 根据第三个参数创建了一个应用程序对象 默认写nil,即创建的是UIApplication类型的对象,此对象看成是 ...
- iOS代码规范(OC和Swift)
下面说下iOS的代码规范问题,如果大家觉得还不错,可以直接用到项目中,有不同意见 可以在下面讨论下. 相信很多人工作中最烦的就是代码不规范,命名不规范,曾经见过一个VC里有3个按钮被命名为button ...
- JS调用Android、Ios原生控件
在上一篇博客中已经和大家聊了,关于JS与Android.Ios原生控件之间相互通信的详细代码实现,今天我们一起聊一下JS调用Android.Ios通信的相同点和不同点,以便帮助我们在进行混合式开发时, ...
- 告别被拒,如何提升iOS审核通过率(上篇)
iOS审核一直是每款移动产品上架苹果商店时面对的一座大山,每次提审都像是一次漫长而又悲壮的旅行,经常被苹果拒之门外,无比煎熬.那么问题来了,我们有没有什么办法准确把握苹果审核准则,从而提升审核的通过率 ...
- Swift3.0服务端开发(一) 完整示例概述及Perfect环境搭建与配置(服务端+iOS端)
本篇博客算是一个开头,接下来会持续更新使用Swift3.0开发服务端相关的博客.当然,我们使用目前使用Swift开发服务端较为成熟的框架Perfect来实现.Perfect框架是加拿大一个创业团队开发 ...
- Summary of Critical and Exploitable iOS Vulnerabilities in 2016
Summary of Critical and Exploitable iOS Vulnerabilities in 2016 Author:Min (Spark) Zheng, Cererdlong ...
随机推荐
- CSS hover 改变另外一个元素状态
Part.1 问题 我们写页面时也不少遇到这个问题,在没有使用任何预处理语言前提下,当hover 一个元素的时候怎么改变其它的元素? 这里我把它分为两种情况(除自身以外) hover时 1: 改变本身 ...
- 笔试算法题(42):线段树(区间树,Interval Tree)
议题:线段树(Interval Tree) 分析: 线段树是一种二叉搜索树,将一个大区间划分成单元区间,每个单元区间对应一个叶子节点:内部节点对应部分区间,如对于一个内部节点[a, b]而言,其左子节 ...
- 基于Docker Compose搭建mysql主从复制(1主2从)
系统环境 * 3 Ubuntu 16.04 mysql 8.0.12 docker 18.06.1-ce docker-compose 1.23.0-rc3 *3 ==> PS ###我用的是 ...
- 零基础入门学习Python(8)--了不起的分支和循环2
前言 上节课小甲鱼教大家如何正确的打飞机,其要点是判断和循环,判断就是该不该做某事,循环就是持续做某事 知识点 写一个程序 按照100分制,90分以上成绩为A,80到90为B,60到80为C,60以下 ...
- ArcGIS:Hello World Maps
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout ...
- Html、Css、JavaScript 遇到的问题总结
$('body').scrollTop()无效得解决方案 鼠标滑轮获取到得值为0:var scrollTop = $('body').scrollTop(); 在页面中加一个随着页面滚动条滚动的小图片 ...
- Linux最常用的基础命令 上篇
Linux最常用的基础命令个人总结 计算机基础知识 32bit和64bit系统的区别.系统运行机制 1989年python 诞生 C语言是编译型的语言,不太支持跨平台 Django 江购 32bit= ...
- orcad中的快捷键
在画原理图的时候,不能正常的将将要放下的器件与旁边的对其,一种解决办法是按F6,调出大的水平竖直线,在按F6,此线标消失. Ctrl+F8是全屏模式,关闭的方法暂时不知道,退出方式是点击按钮. F10 ...
- ..net 3.5新特性之用this关键字为类添加扩展方法
具体用法如下: public static class ClassHelper { //用this 声明将要吧这个方法附加到Student对象 public static bool CheckName ...
- 【Codeforces 1042D】Petya and Array
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 把a[i]处理成前缀和 离散化. 枚举i从1..n假设a[i]是区间和的a[r] 显然我们需要找到a[r]-a[l]<t的l的个数 即a ...