//

//  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的更多相关文章

  1. iOS可视化动态绘制连通图

    上篇博客<iOS可视化动态绘制八种排序过程>可视化了一下一些排序的过程,本篇博客就来聊聊图的东西.在之前的博客中详细的讲过图的相关内容,比如<图的物理存储结构与深搜.广搜>.当 ...

  2. 【疯狂造轮子-iOS】JSON转Model系列之二

    [疯狂造轮子-iOS]JSON转Model系列之二 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 上一篇<[疯狂造轮子-iOS]JSON转Model系列之一> ...

  3. 【疯狂造轮子-iOS】JSON转Model系列之一

    [疯狂造轮子-iOS]JSON转Model系列之一 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 之前一直看别人的源码,虽然对自己提升比较大,但毕竟不是自己写的,很容易遗 ...

  4. iOS总结_UI层自我复习总结

    UI层复习笔记 在main文件中,UIApplicationMain函数一共做了三件事 根据第三个参数创建了一个应用程序对象 默认写nil,即创建的是UIApplication类型的对象,此对象看成是 ...

  5. iOS代码规范(OC和Swift)

    下面说下iOS的代码规范问题,如果大家觉得还不错,可以直接用到项目中,有不同意见 可以在下面讨论下. 相信很多人工作中最烦的就是代码不规范,命名不规范,曾经见过一个VC里有3个按钮被命名为button ...

  6. JS调用Android、Ios原生控件

    在上一篇博客中已经和大家聊了,关于JS与Android.Ios原生控件之间相互通信的详细代码实现,今天我们一起聊一下JS调用Android.Ios通信的相同点和不同点,以便帮助我们在进行混合式开发时, ...

  7. 告别被拒,如何提升iOS审核通过率(上篇)

    iOS审核一直是每款移动产品上架苹果商店时面对的一座大山,每次提审都像是一次漫长而又悲壮的旅行,经常被苹果拒之门外,无比煎熬.那么问题来了,我们有没有什么办法准确把握苹果审核准则,从而提升审核的通过率 ...

  8. Swift3.0服务端开发(一) 完整示例概述及Perfect环境搭建与配置(服务端+iOS端)

    本篇博客算是一个开头,接下来会持续更新使用Swift3.0开发服务端相关的博客.当然,我们使用目前使用Swift开发服务端较为成熟的框架Perfect来实现.Perfect框架是加拿大一个创业团队开发 ...

  9. Summary of Critical and Exploitable iOS Vulnerabilities in 2016

    Summary of Critical and Exploitable iOS Vulnerabilities in 2016 Author:Min (Spark) Zheng, Cererdlong ...

随机推荐

  1. winpcap编程设置过滤器之指定获取某个网站的数据

    下面,我将以 乱世隋唐页游 为例,通过编码获取这里面的数据. 游戏图: 我是乱世隋唐的网址是:www.917st.com 这个是官网网址的服务器地址.  42.62.0.14 我玩的游戏服是84区.网 ...

  2. TCP/IP 协议分层

    协议分层 可能大家对OSI七层模型并不陌生,它将网络协议很细致地从逻辑上分为了7层.但是实际运用中并不是按七层模型,一般大家都只使用5层模型.如下: 物理层:一般包括物理媒介,电信号,光信号等,主要对 ...

  3. CAD参数绘制固定批注(网页版)

    js中实现代码说明: 自定义实体绘制函数 function ExplodeFun(pCustomEntity, pWorldDraw, txt) { var sGuid = pCustomEntity ...

  4. formatDate() 格式化日期

    function datefmt(milSec, format) { var oldTime = Number(milSec); //得到毫秒数 // 日期格式转换 var t = new Date( ...

  5. vuex如何管理需要即时更新的全局变量

    自己在使用vue练习开发的时候遇到全局变量无法即时更新的问题,查了资料之后得出结论使用vuex能够快速解决该问题,但是看了好多人讲解vuex的教程自己跟着去做都没解决自己想要的,最后找到一个比较容易理 ...

  6. (3)Gojs model简介

    (3)Gojs model简介 在GoJS中,model用来存储表的基本数据,包括node.link等具体对象和属性,与其在视觉上的展示效果不相关.model中往往只保存相对简单的数据,最方便且持久化 ...

  7. HDU1401 Solitaire

    题目描述:8×8的棋盘上有4个棋子,棋子的运动方法如下:1.如果其上/下/左/右一格没有棋子,则可以去;2.如果其上/下/左/右一格有棋子,而且沿原方向再跳一步没有,则可以去. 给出初始结束位置,问8 ...

  8. 如何使用 Laravel Collections 类编写神级代码

    本文首发于 如何使用 Laravel Collections 类编写神级代码,转载请注明出处. Laravel 提供了一些超赞的组件,在我看来,它是目前所有 Web 框架中提供组件支持最好的一个.它不 ...

  9. rbac组件之权限操作(四)

    对于权限表的操作有两种方式,第一种是一个个的权限进行curd,另外一种是批量操作,自动发现django程序中的路由,进行批量curd,首先介绍第一种方式. 因为在列出菜单时,已经将权限列表列出来了,所 ...

  10. hihocoder 1515 分数调查(树形dp)

    hihocoder 1515 分数调查 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi的学校总共有N名学生,编号1-N.学校刚刚进行了一场全校的古诗文水平测验. ...