2016-2-20 Week Summary

Source: Internet
Author: User

There is no reasonable plan to put yourself in a particularly awkward situation, from now on to have a reasonable plan, the weekly work content, daily work content, daily and weekly, the monthly study progress should have a clear plan.

One. Use of the block pass value.

1. Now there is an example, you need to input the controller B text, the value to control a label, how to use block implementation?

//-----Controller B//. htypedefvoid(^returntext) (NSString *text);//Returntext is the name of the block, text is the parameter passed//Define block@property (nonatomic,copy) returntext returntext;//return to block method- (void) Returntext: (Returntext) Returntext;//. M- (void) Returntext: (returntext) returntext{Self.returntext=Returntext;}- (void) Viewwilldisappear: (BOOL) animated{[Super viewwilldisappear:animated]; //Set block value        if(Self.returntext) {//is not empty, that is, controller a needs to call it, otherwise this block is emptyself.returetext (text); }}
// Controller A calls the Controller B block controller B *b = [[controller B alloc] init];    [B returndata: // This is the key code, and if it is not called, the block is empty                 = text;    }];       [Self.navigationcontroller pushviewcontroller:b Animated:yes];

Two. Camera and album use and add photo album logic analysis

1.1 Use of cameras and albums

// Create a camera, album Uiimagepickercontroller *CAMERAPC = [[Uiimagepickercontroller alloc] INIT];CAMERAPC. delegate == Uiimagepickercontrollersourcetypecamera;        // Camera  // albums [self PRESENTVIEWCONTROLLER:CAMERAPC animated:yes completion:nil];

1.2 Proxy callback method

Need to import #import <MobileCoreServices/MobileCoreServices.h> frame, add and import header files in Framwork

- (void) Imagepickercontroller: (Uiimagepickercontroller *) Picker Didfinishpickingmediawithinfo: (NSDictionary<NSString *,ID> *) info{[picker dismissviewcontrolleranimated:yes Completion:nil]; NSString*mediatype =Info[uiimagepickercontrollermediatype]; UIImage*tempimg; if([MediaType isequaltostring: (__bridge NSString *) {Kuttypeimage]) {/*Let ' s get the metadata. This was only for images. Not videos*/nsdictionary*metadata =Info[uiimagepickercontrollermediametadata]; UIImage*theimage =info[uiimagepickercontrolleroriginalimage];//Original//Interface Displaytempimg=theimage;    } [Self.imagearray addobject:tempimg]; [Self Handleshowselectionandcameraphotos];}

Three. Keyboard return events and TextView settings placeholder (concealed text)

//set the hidden text, the idea is to create a label, put on the TextView, and set enable to No, when the text changes, hide the label, otherwise displayed.-(BOOL) TextView: (Uitextview *) TextView Shouldchangetextinrange: (nsrange) Range Replacementtext: (NSString *) text{//because done is \ n,    if([Text isequaltostring:@"\ n"]) {[TextView resignfirstresponder]; if(!textView.text.length) {Self.placeholderL.text=@"Please describe your question"; }Else{Self.placeholderL.text=@""; }        returnNO; }    returnYES;}

2016-2-20 Week Summary

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.