• iphone开发第二个程序


    此程序包括UIProgressViewUIButton, 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

  • 相关阅读:
    浅析如何让 (a === 1 && a === 2 && a === 3) 返回 true
    浅析单点登录的三种实现方式
    浅析瀑布流布局原理及实现方式
    浅析Java中三目运算符可能产生的坑
    【转】IO
    [转]gomonkey学习
    从sha1的计算例子,理解计算机的数据表示?16进制输出?二进制输出??
    [转]Golang第三方包应该如何安装--在线和离线
    【转】goconvey使用
    go import 时 点号 和下划线的区别
  • 原文地址:https://www.cnblogs.com/zhao123/p/3200216.html
Copyright © 2020-2023  润新知