Date Picker and Uitool bar controls Brief Introduction

Source: Internet
Author: User

Date Picker and Uitool Bar controls Brief Introduction A. Date Picker control1. Brief Introduction: Date picker display time of the control has the default width high, do not set the data source and agent how to change to Chinese? (1) Check whether the current system is in Chinese, change the simulator to be Chinese (2) attribute, locale Select Region if the default display does not meet the requirements. There are four modes of time that can be set, and the setup time in model can be customized (custom). Set the minimum and maximum time, which will automatically return to the minimum time. The biggest use is to customize the keyboard: Pop out a date selector, the sample code is as follows: 2. Sample code
1//2//YYVIEWCONTROLLER.M 3//DatePicker 4//5//Created by Apple on 14-6-3. 6//Copyright (c) 2014 itcase. All rights reserved. 7//8 9 #import "YYViewController.h" @interface Yyviewcontroller () 12/**13 * Text input box */15 @property (Strong, no     natomic) Iboutlet Uitextfield *textfield;16 @end18 @implementation YYViewController20-(void) ViewDidLoad22 {23      [Super Viewdidload];24//125//Add a time selector for Uidatepicker *date=[[uidatepicker alloc]init];27/**28      * Settings only display Chinese */30 [date setlocale:[nslocale localewithlocaleidentifier:@ "ZH-CN"]];31/**32 * Settings only display date 33 */34 date.datepickermode=uidatepickermodedate;35//[Self.view addsubview:date];3637//When the cursor moves to the text box, summon the time selector to self.textfield.inputview=date;39 40//241//Create toolbar Uitoolbar *toolbar=[[uitoolbar alloc]init];43//Set the color of the toolbar Toolbar.bartintco         Lor=[uicolor browncolor];45//Settings toolbar Frame46 toolbar.frame=cgrectmake (0, 0, 320, 44); 47 48//Add a button to the toolbar 49 Uibarbuttonitem *item0=[[uibarbuttonitem alloc]initwithtitle:@ "Previous" Style:uibarbuttonitemstyleplain target:self Action: @selector (click)];50 wuyi uibarbuttonitem *item1=[[uibarbuttonitem alloc]initwithtitle:@ "Next" Style:uiba Rbuttonitemstyleplain target:self Action: @selector (click)];52 uibarbuttonitem *item2=[[uibarbuttonitem allo C]initwithbarbuttonsystemitem:uibarbuttonsystemitemflexiblespace Target:nil action:nil];54 UIBarButtonItem *item3= [[Uibarbuttonitem alloc]initwithtitle:@ "completed" Style:uibarbuttonitemstyleplain target:self Action: @selector (click)]; Toolbar.items = @[item0, Item1, item2, item3];57//auxiliary view for setting text input box keyboardSelf.textfield.inputaccessoryview=toolbar;}60-(void) click61 {NSLog (@ "toolbar");}64 @end

Implementation results:

Second, Uitool BarYou can add child controls above toolbar only Uibarbuttonitem child controls are added, and other child controls are wrapped scales the above controls of this type are then emitted (spaces ————) with styles, which can be specified as styles (stretchable) and are generally used as toolbars. How to make a la carte system centered by using toolbar for the head title? It is positive in IOS6 and is crooked in iOS7. Add a toolbar to your custom keyboard. The order in which they are placed in the array is shown in what sequence.
  Toolbar.items = @[item0, Item1, item2, item3];    Sets the text input box Keyboard auxiliary view    Self.textfield.inputaccessoryview=toolbar;

Date Picker and Uitool bar controls Brief Introduction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.