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