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?
- [UIView TransitionWithView:self.view
- duration:0.2
- Options:uiviewanimationoptiontransitionflipfromleft
- animations:^{
- [[Blueviewcontroller view] removefromsuperview];
- [Self view] insertSubview:yellowViewController.view atindex:0];
- }
- Completion:null
- ];
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