Stanford University Open Class: IOS 7 App Development Lecture10

Source: Internet
Author: User

1.now,this line of code could cause trouble. If Self.image is Nil,because I told if you have a method,this are just a getter of the image that returns a struct , and you send it to nil,you ' ll get undefined results. (47:00) 2.Zomming in,really Simple,remember I said you have need to do II Things,okay? One is your got to set the ScrollView ' s minimum and maximum zoom scale. And the other thing we need to do besides setting those are to set the ScrollView ' s delegate and implement, other Metho D. 3.Main Queue:there is a very special queue called the "Main queue". All UI activity must occur on the this queue and the this queue only. And conversely,non-ui activity that was at the all time consuming must not occur on the that queue. We want our UI ti is responsive! Blocks is pulled off and worked on the main queue only if it is "quiet". 4.Executing a block on another queue:
dispatch_queue_t queue = ...; Dispatch_async (queue,^{});
Getting the main queue
dispatch_queue_t mainq =*mainq = [Nsoperationqueue mainqueue]; // For object-oriented APIs
Creating a queue (not the main queue)
dispatch_queue_t Otherq = dispatch_queue_create ("name", NULL); // name a const char *!
Easy Mode...invoking A method on the main queue
-(void) Performselectoronmainthread: (SEL) Amethod withobject: (ID) obj waituntildone (BOOL) Waituntildone;dispatch_async (Dispatch_get_main_queue (),^{/*Calla method*/});
5.Example of an IOS API uses multithreading:
Nsurlrequest *request = [nsurlrequest requestwithurl:[nsurl urlwithstring:@ "http://..."]; Nsurlconfiguration *configuration =*session =*= [Session Downloadtaskwithrequest:request completionhandler:^ (Nsurl *localfile,nsurlresponse *response,nserror *error) {}]; [Task resume];
DownloadTaskWithRequest:completionHandler:will Do it work (downloading the URL). Not in the main thread (i.e.it won't block the UI while it waits is not the network). The Completionhandler block above might execute on the main thread (or not) depending on how do you create the Nsurlsession.on The main queue ...
 nsurlsession *session = [Nsurlsession sessionwithconfiguration:configuration 
delegate :nil
Delegatequeue:[nsoperationqueue Mainqueue]]; Nsurlsessiondownloadtask *task;task = [Session Downloadtaskwithrequest : Request completionhandler:^ (Nsurl *localfile,nsurlresponse *response,nserror *error { // }]; [Task resume];
Since The Delegatequeue is the main queue,our Completionhandler'll be on the main queue. When the URL was done downloading,the block above would execute on the main queue. Thus we can do any UI code we want there. Off the main queue ...
Nsurlsession *session = [Nsurlsession sessionwithconfiguration:configuration]; // No Delegatequeue Nsurlsessiondownloadtask *= [Session Downloadtaskwithrequest:request
completionhandler:^ (Nsurl *localfile,nsurlresponse *response,nserror *error) {Dispatch_async (dispatch_get_main _queue (),^{//doUI Things}); or
[Self Performselectoronmainthread: @selector (douithings) Withobject:nil waituntildone:no];}]; [Task resume];
In this case,you can ' t does any UI stuff because the completionhandler are not on the main queue. The To do UI Stuff,you has to post a block (or call a method) and back on the main queue. 6.How Do you create a uiscrollview? Just like any and uiviews.drag out with a storyboard or use Alloc/initwithframe:. Or Select a UIView in your storyboard and choose "Embed in, Scroll View" from Editor menu. Or add your "too big" UIView using Addsubview:
UIImage *image =*iv = [[Uiimageview alloc]initwithimage:image]; // frame.size = image.size [ScrollView Addsubview:iv];
All of the subviews ' frame would be in the Uiscrollview's content area ' s coordinate system. (That's, (0,0) in the upper left & width and height of contentsize.width &. Height). Don ' t forget to set the Contentsize:common bug was to does the above 3 lines of code (or embed in Xcode) and forget to Say:scro Llview.contentsize = imageView.bounds.size; 7.zooming:all UIView ' s has a property (transform) which was an affine transform (translate,scale,rotate). Scroll View simply modifies this transform when you zoom. Zooming is also going to affect the scroll view ' s contentsize and Contentoffset.will not work without minimum/maximum zoom Scale being set:
0.52.0;
Won't work without delegate method to specify view to zoom
-(UIView *) Viewforzoominginscrollview: (Uiscrollview *) sender;
If your scroll view only have one subview,you return it here. More than one? Up-to-you.

Stanford University Open Class: IOS 7 App Development Lecture10

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.