IOS Interview---animation block

Source: Internet
Author: User

1 Talk about the understanding of block? and write out a uivew animation using block?

Answer: Block is an anonymous function that can get local variables of other functions, which is not only convenient for development, but also can greatly improve the execution efficiency of the application (multi-core CPU can directly handle the block instruction)

[CPP]View Plaincopyprint?
  1. [UIView TransitionWithView:self.view
  2. duration:0.2
  3. Options:uiviewanimationoptiontransitionflipfromleft
  4. animations:^{
  5. [[Blueviewcontroller view] removefromsuperview];
  6. [Self view] insertSubview:yellowViewController.view atindex:0];
  7. }
  8. Completion:null
  9. ];

2 Write the block definition of the above code.

Answer:

typedef void (^animations) (void);

typedef void (^completion) (BOOL finished);

3 try to use + beginanimations:context: And the definition of the block above, write a complete

+ (void) Transitionwithview: (UIView *) View Duration: (nstimeinterval) Duration options: (uiviewanimationoptions) Options animations: (void (^) (void)) animations completion: (void (^) (BOOL finished)) Completion Ns_available_ios (4_0); function execution part of the operation

Answer: None

IOS Interview---animation block

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.