Introduction and use of new APIs in iOS 5

Source: Internet
Author: User

Original address: introduction and use of new APIs in iOS 5

1. uistepper

UIStepper *stepper = [[UIStepper alloc] initWithFrame:CGRectMake(200, 100, 0, 0)];    [stepper sizeToFit];    stepper.value = 0;    stepper.minimumValue = 0;    stepper.maximumValue = 1;    stepper.stepValue = 0.1;    [stepper addTarget:self action:@selector(stepperAction:) forControlEvents:UIControlEventValueChanged];    [self.view addSubview:stepper];    [stepper release];
- (void)stepperAction:(UIStepper *)stepper{    NSLog(@"stepper value:%f",stepper.value);}

2. uialertview Style

Uialertview * Alert = [[uialertview alloc] initwithtitle: @ "hello" message: @ "Hello World" delegate: Nil cancelbuttontitle: Nil otherbuttontitles: nil, nil]; // The first figure alert. alertviewstyle = uialertviewstyleplaintextinput; // The second figure is alert. alertviewstyle = uialertviewstyleloginandpasswordinput; // Figure 3 alert. alertviewstyle = uialertviewstylesecuretextinput; [alert show]; [alert release];
// Return the textfield of the specified index value. This API only exists in the fields above ios5.0-(uitextfield *) textfieldatindex :( nsinteger) textfieldindex {return textfield ;}
3 uiscreen adjust brightness
Uiscreen * mainscreen = [uiscreen mainscreen]; // set the screen brightness to 50% mainscreen. brightness = 0.5; // No by default. If yes, you can use the wantssoftwaredimming attribute to declare that the application needs to adjust the screen brightness to a level that is darker than the moderate brightness. (It should be noted that opening wantssoftwaredimming may affect the performance, because this darkness is achieved through software .) Mainscreen. wantssoftwaredimming = yes;

4 uireferencelibraryviewcontroller

Nsstring * Key = @ "hello"; // determines if ([uireferencelibraryviewcontroller dictionaryhasdefinitionforterm: Key]) definitions of keys in any installed dictionary. {parameters * controller = [[uireferencelibraryviewcontroller alloc] initwithterm: Key]; // only the switching mode is [controller setmodaltransitionstyle: Custom]; [self presentmodalviewcontroller: controller animated: Yes]; [controller release];}

5. uisplitviewcontroller delegate. When hidden, the delegate
Uisplitviewcontroller

// This delegate method is sent to your delegate to ask you what you want to do on the left side in a specific direction, so it passes itself to you, and on the left side, it will ask you in this direction What You Want Me To Do on the left. Yes is returned if you want to hide it. If you want to keep it on the screen, no-(bool) splitviewcontroller :( uisplitviewcontroller *) SVC shouldhideviewcontroller :( uiviewcontroller *) VC inorientation :( uiinterfaceorientation) orientation ;}

6. Obtain the cell from the XIB file and create uitableviewcell.

// Register a nib uinib * nib = [uinib nibwithnibname: @ "mycell" Bundle: Nil] For tableview; [self. tableview registernib: nib forcellreuseidentifier: @ "identifier"];
-(Uitableviewcell *) tableview :( uitableview *) tableview cellforrowatindexpath :( nsindexpath *) indexpath {// reuse the previously registered cell uitableviewcell * cell = [tableview metadata: @ "identifier"]; // other codereturn cell ;}

7. uiimage and image Animation
8 uiappearance: A Powerful UI modification tool for all attributes in iOS 5-uiappearance

// Change all slider values in the program to red [[uislider appearance] setminimumtracktintcolor: [uicolor redcolor];

9 uipageviewcontrolleruipageviewcontroller-the analysis control provides us with a control that looks like a book flip effect. We can use the uipageviewcontroller control to control pages similar to books.

10 uiphoneentiphone development-preparation for iCloud Development
Support for iCloud notes

11 manage the resource library alassetslibrary-code to operate IOS album Resources
Alassetslibrary provides our access to photos and videos on iOS devices.

You can use valueforproperty to obtain the image information, including the type, location, duration, direction, date, format, and URL address.

Self. view. backgroundcolor = [uicolor whitecolor]; self. assetslibrary = [[alassetslibrary alloc] init]; dispatch_queue_t dispatchqueue = random (random, 0); dispatch_async (dispatchqueue, ^ (void) {// all picture albums [self. assetslibrary enumerategroupswithtypes: alassetsgroupall usingblock: ^ (alassetsgroup * group, bool * Stop) {// traverses items in each album alasset [Group enumerateasset Susingblock: ^ (alasset * result, nsuinteger index, bool * Stop) {_ block bool foundthephoto = no; If (foundthephoto) {* Stop = yes ;} // alasset type nsstring * assettype = [result valueforproperty: alassetpropertytype]; // if it is a photo // alassettypevideo // alassettypeunknown if ([assettype is1_tostring: Unknown]) {foundthephoto = yes; * Stop = yes; // encapsulate alasset, which contains many attributes in a resource file. (It can be said that different representations of alasset are essentially the same resource file.) alassetrepresentation * assetrepresentation = [result defaultrepresentation]; cgfloat imagescale = [assetrepresentation scale]; uiimageorientation imageorientation = (uiimageorientation) [assetrepresentation orientation]; reverse (partial (), ^ (void) {cgimageref imagereference = [assetrepresentation partial]; // operate uiimage on the Image * Image = [[uiimage alloc] initwithcgimage: imagereference scale: imagescale orientation: imageorientation]; If (image! = Nil) {// present self. imageview = [[uiimageview alloc] initwithframe: Self. view. bounds]; self. imageview. contentmode = uiviewcontentmodescaleaspectfit; self. imageview. image = image; [self. view addsubview: Self. imageview];} else {nslog (@ "failed to create the image. ") ;}}) ;}}] ;}failureblock: ^ (nserror * error) {// read failed processing}] ;});

12 how does glkit create a simple glkit application for ios5?

13. New Features of core imageios5: powerful core image

14 core data [cocoa] go deep into cocoa core data (1)-detailed framework

Related Article

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.