技术处女贴 欢迎来探讨

转帖请注明出处 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. 模块"xxxx.dll"已加载,但对DllRegisterServer的调用失败,错误代码为 XXXXXXXXX

    WIN7.WIN8  注册 卸载dll  报错: 模块"xxxx.dll"已加载,但对DllRegisterServer的调用失败,错误代码为 XXXXXXXXX 解决方法: 若为 ...

  2. ContentProvider官方教程(7)3种访问形式:批处理、异步访问、intent间接访问(临时URI权限)

    Alternative Forms of Provider Access Three alternative forms of provider access are important in app ...

  3. MVC系列之一 入门概述

    一 概述 MVC作为一种当前比较好的开发web的框架,不得不提一下了,和WebForm比较来看,有了很大的进步和改进. 先进行一个简单的比较,两个都是Web开发框架,理念仍然是较快速开发. 不过MVC ...

  4. Hadoop分布式部署——要点

    这里只记录几个要点,比较容易出问题的地方. 1.各服务器必须有相同的用户(便于使用相同的用户ssh登录)2.ssh互通,配置无密码登录ssh-keygen -t rsa,将id_rsa.pub的内容相 ...

  5. Upgrade R (升级R语言)

    R R version 3.1.1 (2014-07-10) -- "Sock it to Me" yum list installed | grep R R-core.x86_6 ...

  6. Hibernate+Struts2+jsp 修改用户信息

    在用户列表页面点击修改,进入修改页面 修改薪酬为555,点击提交,重新跳回该页面 修改成功 关键代码如下 基层的代码,这里增加了一个根据用户id查询的方法 dao层 //修改 public USer ...

  7. Java开发中经典的小实例-(随机数)

    import java.util.Random;//输出小于33的7个不相同的随机数public class probability {    static Random random = new R ...

  8. 部署PDA程序的时候存储不足的解决办法

    通常Windows Mobile的存储空间分为程序内存和存储内存,默认都比较小,当程序比较大的时候可能无法正常部署到设备上面,针对此问题可采用如下办法解决:1.通过VS修改,工具--选项--设备--选 ...

  9. P2P小贷网站业务数据流程分享

    P2P小贷网站业务数据流程分享 引言 这是去年年底开发的一个项目,完成后和用户的衔接没有很好的做起来,所以项目就搁浅了.9月以来,看各路P2P风声水起,很是热闹:这里分享下我的设计文档,算是抛砖引玉, ...

  10. 创建XML

    //创建XML XElement xelement = new XElement("request", new XElement("head", new XEl ...