iOS Development UI Chapter-date Picker and Uitool bar controls Brief Introduction

Source: Internet
Author: User

iOS Development UI Chapter-date Picker and Uitool Bar controls Brief Introduction A. Date Picker control1. Brief Introduction: Date picker controls that display timeThere is a default wide height without setting up the data source and proxyHow 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.M3 //DatePicker4 //5 //Created by Apple on 14-6-3.6 //Copyright (c) 2014 itcase. All rights reserved.7 //8 9 #import "YYViewController.h"Ten  One @interfaceYyviewcontroller () A /** - * Text input box -  */ the@property (Strong, nonatomic) iboutlet Uitextfield *TextField; -  - @end -  + @implementationYyviewcontroller -  +- (void) Viewdidload A { at [Super Viewdidload]; -     //1 -     //Add a Time selector -Uidatepicker *date=[[Uidatepicker alloc]init]; -     /** - * Set display only in Chinese in      */ -[Date Setlocale:[nslocale Localewithlocaleidentifier:@"ZH-CN"]]; to     /** + * Set only display date -      */ theDate.datepickermode=uidatepickermodedate; * //[Self.view addsubview:date]; $     Panax Notoginseng     //when the cursor moves to the text box, summon the time picker -     self.textfield.inputview=date;  the      +     //2 A     //Create a tool bar theUitoolbar *toolbar=[[Uitoolbar alloc]init]; +     //set the color of the toolbar -Toolbar.bartintcolor=[Uicolor Browncolor]; $     //set the frame of the toolbar $Toolbar.frame=cgrectmake (0,0, the, -); -      -     //Add a button to a toolbar theUibarbuttonitem *item0=[[uibarbuttonitem Alloc]initwithtitle:@"previous"Style:uibarbuttonitemstyleplain target:self Action: @selector (click)]; -     WuyiUibarbuttonitem *item1=[[uibarbuttonitem Alloc]initwithtitle:@"Next"Style:uibarbuttonitemstyleplain target:self Action: @selector (click)]; the      -Uibarbuttonitem *item2=[[Uibarbuttonitem alloc]initwithbarbuttonsystemitem:uibarbuttonsystemitemflexiblespace Target:nil Action:nil] ; WuUibarbuttonitem *item3=[[uibarbuttonitem Alloc]initwithtitle:@"Complete"Style:uibarbuttonitemstyleplain target:self Action: @selector (click)]; -      AboutToolbar.items =@[item0, Item1, item2, item3]; $     //set the secondary view of the text input box keyboard -     self.textfield.inputaccessoryview=toolbar;  - } --(void) Click A { +NSLog (@"Toolbar"); the } - @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];      //  Self.textfield.inputaccessoryview=toolbar;  

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.