技术处女贴 欢迎来探讨

转帖请注明出处 http://www.cnblogs.com/andy-zhou/p/4962135.html

微信: @Andy

1. AppDelegate

AppDelegate.h 文件

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@property (strong, nonatomic) UITabBarController *tabBarController;

@end

AppDelegate.m 文件

#import "AppDelegate.h"
#import "ViewController.h"
#import "AZImageViewController.h" @interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; // ViewController *viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
// self.window.rootViewController = viewController; ViewController *viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
AZImageViewController *imageViewController = [[[AZImageViewController alloc] initWithNibName:@"AZImageViewController" bundle:nil] autorelease]; self.tabBarController = [[UITabBarController new] autorelease];
self.tabBarController.viewControllers = @[viewController, imageViewController];
self.window.rootViewController = self.tabBarController; [self.window makeKeyAndVisible]; return YES;
} - (void)dealloc
{
[_window release];
[super dealloc];
} @end

2. ViewController

ViewController.h 文件

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController

@property (retain, nonatomic) IBOutlet UILabel *status;

- (IBAction)leftButtonPress:(id)sender;

- (IBAction)rightButtonPress:(id)sender;

- (IBAction)setStatusText:(id)sender;

@end

ViewController.m 文件

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

@synthesize status;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = NSLocalizedString(@"First", @"First");
self.tabBarItem.image = [UIImage imageNamed:@"first"];
}
return self;
} - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} - (void)dealloc {
[status release];
[super dealloc];
} - (IBAction)leftButtonPress:(id)sender {
status.text = @"this is left btn";
} - (IBAction)rightButtonPress:(id)sender {
status.text = @"this is right btn";
} - (IBAction)setStatusText:(id)sender { NSString *title = [sender titleForState:UIControlStateNormal];
// status.text = title;
NSString *newLableText = [NSString stringWithFormat:@"Hello, %@ btn", title];
status.text = newLableText;
} @end

ViewController.xib 文件


3. AZImageViewController

AZImageViewController.h 文件

#import "ViewController.h"

@interface AZImageViewController : ViewController

@property (retain, nonatomic) IBOutlet UITextField *nameField;

@property (retain, nonatomic) IBOutlet UITextField *numberField;

@property (retain, nonatomic) IBOutlet UILabel *rateLabel;

- (IBAction)textFieldDoneEditing:(id)sender;

- (IBAction)backgroudTap:(id)sender;

- (IBAction)sliderMove:(id)sender;

@end

AZImageViewController.m 文件

#import "AZImageViewController.h"

@interface AZImageViewController ()

@end

@implementation AZImageViewController

@synthesize nameField;
@synthesize numberField;
@synthesize rateLabel; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = NSLocalizedString(@"Second", @"Second");
self.tabBarItem.image = [UIImage imageNamed:@"second"];
}
return self;
} #pragma mark - Custom Method - (IBAction)textFieldDoneEditing:(id)sender {
[sender resignFirstResponder];
} - (IBAction)backgroudTap:(id)sender {
[nameField resignFirstResponder];
[numberField resignFirstResponder];
} - (IBAction)sliderMove:(id)sender { UISlider *slider = (UISlider *)sender;
NSInteger _rate = (NSInteger)roundf(slider.value);
rateLabel.text = [NSString stringWithFormat:@"%ld", _rate];
} - (void)dealloc {
[nameField release];
[numberField release];
[rateLabel release];
[super dealloc];
}
@end

AZImageViewController.xib 文件


4. info_plist

使用XIB实现一个简单view的更多相关文章

  1. 使用xib封装一个自定义view的步骤

    使用xib封装一个自定义view的步骤 1> 新建一个继承UIView的自定义view,假设类名叫做(MJAppView) 2> 新建一个MJAppView.xib文件来描述MJAppVi ...

  2. iOS开发UI篇—使用xib自定义UItableviewcell实现一个简单的团购应用界面布局

    iOS开发UI篇—使用xib自定义UItableviewcell实现一个简单的团购应用界面布局 一.项目文件结构和plist文件 二.实现效果 三.代码示例 1.没有使用配套的类,而是直接使用xib文 ...

  3. iOS开发UI篇—使用picker View控件完成一个简单的选餐应用

    iOS开发UI篇—使用picker View控件完成一个简单的选餐应用 一.实现效果 说明:点击随机按钮,能够自动选取,下方数据自动刷新. 二.实现思路 1.picker view的有默认高度为162 ...

  4. 相比xib 使用代码编排view 的一个明显的好处就是可以更好地重复使用已有代码,减少代码冗余。

    相比xib 使用代码编排view 的一个明显的好处就是可以更好地重复使用已有代码,减少代码冗余.

  5. 在iOS中实现一个简单的画板App

    在这个随笔中,我们要为iPhone实现一个简单的画板App. 首先需要指出的是,这个demo中使用QuarzCore进行绘画,而不是OpenGL.这两个都可以实现类似的功能,区别是OpenGL更快,但 ...

  6. 创建一个Table View

    在本课程中,您将创建应用程序FoodTracker的主屏幕.您将创建第二个,表视图为主场景,列出了用户的菜谱.你会设计定制表格单元格显示每一个菜谱,它是这样的: 学习目标 在课程结束时,你将能够: 创 ...

  7. Objective-C ,ios,iphone开发基础:快速实现一个简单的图片查看器

    新建一个single view 工程: 关闭ARC , 在.xib视图文件上拖放一个UIImageView  两个UIButton ,一个UISlider ,布局如图. 并为他们连线, UIImage ...

  8. IOS中一个简单的粒子效果实现

    1.效果图展示 2.实现思路 1> 首先要实现上面的效果,第一步要处理的就是一个简单的画板,在View上面用鼠标滑动的时候画出线条,这个功能可使用UIBezierPath实现 2> 关于粒 ...

  9. CSharpGL(23)用ComputeShader实现一个简单的ParticleSimulator

    CSharpGL(23)用ComputeShader实现一个简单的ParticleSimulator 我还没有用过Compute Shader,所以现在把红宝书里的例子拿来了,加入CSharpGL中. ...

随机推荐

  1. JavaBean基础转载

    JavaWeb:JavaBean基础 JavaBean基础 JavaBean简介: 1.JavaBean是一种可以重复使用的类,可以没有用户界面,主要负责业务数据或者处理事物(数据运算.操作数据库) ...

  2. 关于stl string find 容易犯的一个错误

    有时候经常会判断一个字符串a中是否有子字符串b,那么有人会调用 string::find这个函数  这个函数返回子字符串首次出现的位置,那么有人会这样写 string str1 = "&qu ...

  3. Linux 新手非常有用的命令

    http://www.cnblogs.com/felix-/p/4341773.html Linux 新手非常有用的命令 你打算从Windows换到Linux上来,还是你刚好换到Linux上来?哎哟! ...

  4. 基础!winForm客户端最常用的几个基本属性

    客户端应用程序 - 是需要安装在用户电脑上才可以使用的程序特点:不需要联网也可以打开使用部分功能但是现在的情况是许多功能依然需要互联网的支持 代码部分在用户电脑上执行 WinForm常用窗体属性: 布 ...

  5. 利用MDK4中的逻辑分析仪分析IO口的PWM波

    1.先设置软件仿真 ,可参看STM32不完全手册的2.4的软件仿真这一章 (原文件名:1.jpg) Example functionality:                             ...

  6. Struts2配置详解_配置Action

    Struts2的核心功能是action,对于开发人员来说,使用Struts2主要就是编写action,action类通常都要实现com.opensymphony.xwork2.Action接口,并实现 ...

  7. POJ3009 Curling

    题目链接:http://poj.org/problem?id=3009 题意:从2出发,要到达3, 0可以通过,碰到1要停止,并且1处要变成0, 并且从起点开始沿着一个方向要一直前进,直至碰到1(或者 ...

  8. STL--stack

    stack--概述: 栈(Stack)是一种特殊的线性表,只能在某一端插入和删除的特殊线性表.它按照后进先出的原则存储数据,先进入的数据被压入栈底,最后的数据在栈顶.栈也称为先进后出表(LIFO). ...

  9. [poj3349]Snowflake Snow Snowflakes(hash)

    Snowflake Snow Snowflakes Time Limit: 4000MS Memory Limit: 65536K Total Submissions: 37615 Accepted: ...

  10. 解耦HTML、CSS和JavaScript

    当前在互联网上,任何一个稍微复杂的网站或者应用程序都会包含许多HTML.CSS和JavaScript.随着互联网运用的发展以及我们对它的依赖性日益增加,设定一个关于组织和维护你的前端代码的计划是绝对需 ...