iphone开发第二个程序
此程序包括UIProgressView,UIButton, UIDatePicker,UIAlert,UILabel,NSTimer
//
// HViewController.h
// Btn_lbl
//
// Created by public on 13-7-18.
// Copyright (c) 2013年 All rights reserved.
//
#import <UIKit/UIKit.h>
@interface HViewController : UIViewController
@property (retain, nonatomic) IBOutlet UIDatePicker *hdatePicker;
@property (retain, nonatomic) IBOutlet UILabel *lblText;
@property (retain, nonatomic) IBOutlet UIProgressView *progress;
@property (retain, nonatomic) IBOutlet UIProgressView *progressBar;
@property (retain, nonatomic) IBOutlet UIButton *btnStart;
@property (retain, nonatomic) IBOutlet UIButton *btnStop;
@property(retain,nonatomic)IBOutlet NSTimer* timer;
- (IBAction)btnClick:(id)sender;
- (IBAction)dateChange;
- (IBAction)startProgress:(id)sender;
- (IBAction)stopProgress:(id)sender;
- (IBAction)startHeadProgress:(id)sender;
@end
//
// HViewController.m
// Btn_lbl
//
// Created by public on 13-7-18.
// Copyright (c) 2013年 . All rights reserved.
//
#import "HViewController.h"
@interface HViewController ()
@end
@implementation HViewController
#pragma mark 加载数据
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSDate* hdate=[NSDate date];
[_hdatePicker setDate:hdate animated:YES];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)dealloc {
[_lblText release];
[_hdatePicker release];
[_progress release];
[_timer release];
[_btnStart release];
[_progressBar release];
[_btnStop release];
[super dealloc];
}
#pragma mark -按钮的测试点击事件
- (IBAction)btnClick:(id)sender{
UIButton * button=(UIButton *)sender;
_lblText.font=[UIFont fontWithName:@"Bold" size:25];
_lblText.backgroundColor=[UIColor blueColor];
_lblText.textColor=[UIColor whiteColor];
_lblText.text=@"中华";
NSString* tittle=[NSString stringWithFormat:@"UILabel的内容是:%@,UIButton 的 tag 是 %d",_lblText.text,button.tag];
NSString* message=[button currentTitle];
UIAlertView* alert=[[UIAlertView alloc]initWithTitle:tittle message:message delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"cancel", nil];
[alert show];
[alert release];
}
#pragma mark -日历的改变
- (IBAction)dateChange {
NSDate* date=[_hdatePicker date];
NSDateFormatter *format=[[NSDateFormatter alloc]init];
[format setDateStyle:NSDateFormatterShortStyle];
[format setTimeStyle:NSDateFormatterShortStyle];
_lblText.text=[NSString stringWithFormat:@"%@",[format stringFromDate:date]];
[format release];
}
#pragma mark -Progress View进度条
-(void)changetimer
{
_progress.progress+=0.001f;
self.progressBar.progress+=0.001f;
}
- (IBAction)startProgress:(id)sender {
_timer=[NSTimer scheduledTimerWithTimeInterval:0.03f target:self selector:@selector(changetimer) userInfo:nil repeats:YES];
[_timer retain];
[_btnStart setEnabled:NO];
[_btnStop setEnabled:YES];
}
- (IBAction)stopProgress:(id)sender {
[_timer invalidate];
[_timer release];
[_btnStart setTitle:@"继续" forState:UIControlStateNormal];
UIColor *color=[UIColor blueColor];
[_btnStart setTitleColor:color forState:UIControlStateNormal];
[_btnStart setEnabled:YES];
[_btnStop setEnabled:NO];
}
- (IBAction)startHeadProgress:(id)sender {
_progress.progress=0.0f;
_progressBar.progress=0.0f;
[_btnStart setTitle:@"开始" forState:UIControlStateNormal];
UIColor *color=[UIColor blueColor];
[_btnStart setTitleColor:color forState:UIControlStateNormal];
}
@end
最新文章
- [django]django 在apache2上部署静态文件如何加载
- hadoop2.2.0伪分布式搭建3--安装Hadoop
- 递归算法(三)&mdash;&mdash;多项分布问题
- NLS_LANG
- 用Reveal分析第三方App的UI
- ASP.NET中如何读取和写入注册表
- SAM4E单片机之旅——23、在AS6(GCC)中使用FPU
- php读取memcahed java session
- cadence通过孔焊盘的制作
- 如何让Vim显示dos下的^M符号
- 闲话:你今天OO了吗?
- linux下环境搭建比较
- linux之SQL语句简明教程---UNION ALL
- float 浮点数与零值0比较大小
- CSS3属性之border-radius
- 高速理解掌握node.js 字符编码,确码过程 以及base64编解码原理
- HDU 5652 India and China Origins 二分优化+BFS剪枝
- 【Ubuntu】您没有查看“sf_VirtualDisk”的内容所需的权限。
- dashDB - Creating a table with CLOB column type
- 1.3创建项目「深入浅出ASP.NET Core系列」