Knowledge points of internal and external interface dependency and UIScrollView, and uiscrollview
1: Class Extension can also skillfully solve an interface exposure problem.
Some attributes or methods can be provided externally, and some can be called only for internal classes;
// Sark.framework/Sark.h@interface Sark : NSObject@property (nonatomic, copy) NSString *name;@property (nonatomic, copy) NSString *creditCardPassword; // secret!@end// Sark.framework/PrivateSarkWife.h@interface PrivateSarkWife : NSObject- (void)robAllMoneyFromCreditCardOfSark:(Sark *)sark; // needs password!@end
Suppose that Sark. h is the only exposed Header of Sark. framework, and a private class in the framework needs to obtain an attribute (or method) of this public class. What should I do? PrivateSarkWife is a Class inside the Sark. framework. The creditCardPassword attribute above requires a declaration that is invisible to the outside but visible to the inside. In this case, you can use Class Extension:
// Sark.h@interface Sark : NSObject@property (nonatomic, copy) NSString *name;@end// Sark+Internal.h <--- new@interface Sark ()@property (nonatomic, copy) NSString *creditCardPassword;@end// Sark.m#import "Sark.h"#import "Sark+Internal.h" // <--- new
Remove the public and private services in the form of Class Extension into two headers, In the Sark. both header files are referenced in m, and CreditCardPassword is defined in Sark + Internal. in the header file of h, the dependency of the private class on the private property is isolated successfully:
// PrivateSarkWife. m # import "PrivateSarkWife. h "# import" Sark + Internal. h "// <--- private dependency @ implementation PrivateSarkWife-(void) robAllMoneyFromCreditCardOfSark :( Sark *) sark {NSString * password = sark. creditCardPassword; // oh yeah !} @ End
2: UIScrollView knowledge point
-(Void) viewDidLoad {[super viewDidLoad]; scrollView = [[UIScrollView alloc] initWithFrame: CGRectMake (0, 0,320,460)]; scrollView. backgroundColor = [UIColor redColor]; // whether sliding to the top is supported // scrollView. scrollsToTop = NO; scrollView. delegate = self; // sets the content size to scrollView. contentSize = CGSizeMake (320,460*10); // whether to rebound // scrollView. bounces = NO; // whether the page is displayed // scrollView. pagingEnabled = YES; // whether to scroll // scrollView. scrollEnabled = NO; // scrollView. showsHorizontalScrollIndicator = NO; // set the indicator style // scrollView. indicatorStyle = UIScrollViewIndicatorStyleWhite; // sets the content edge and Indicators edge // scrollView. contentInset = UIEdgeInsetsMake (0, 50, 50, 0); // scrollView. scrollIndicatorInsets = UIEdgeInsetsMake (0, 50, 0, 0); // The system prompts the user, Indicators flash [scrollView flashScrollIndicators]; // whether the motion is simultaneous, and lock the scrollView. directionalLockEnabled = YES; [self. view addSubview: scrollView]; UILabel * label = [[UILabel alloc] initWithFrame: CGRectMake (0,200,320, 40)]; label. backgroundColor = [UIColor yellowColor]; label. text = @ "Learn scrolleview"; [scrollView addSubview: label]; [label release];} # pragma mark-/* // return a enlarged or reduced view-(UIView *) viewForZoomingInScrollView :( UIScrollView *) scrollView {} // start to zoom in or out-(void) details :( UIScrollView *) scrollView withView :( UIView *) view {}// when the scaling ends-(void) scrollViewDidEndZooming :( UIScrollView *) scrollView withView :( UIView *) view atScale :( float) scale {} // The view has been zoomed in or out-(void) scrollViewDidZoom :( UIScrollView *) scrollView {NSLog (@ "scrollViewDidScrollToTop ");} * /// whether sliding to the top is supported-(BOOL) scrollViewShouldScrollToTop :( UIScrollView *) scrollView {return YES;} // call this method when sliding to the top-(void) scrollViewDidScrollToTop :( UIScrollView *) scrollView {NSLog (@ "scrollViewDidScrollToTop");} // scrollView sliding-(void) scrollViewDidScroll :( UIScrollView *) scrollView {NSLog (@ "scrollViewDidScroll");} // scrollView start dragging-(void) preview :( UIScrollView *) scrollView {NSLog (@ "scrollViewWillBeginDragging ");} // scrollView end drag-(void) scrollViewDidEndDragging :( UIScrollView *) scrollView willDecelerate :( BOOL) decelerate {NSLog (@ "scrollViewDidEndDragging ");} // scrollView starts to slow down (the following two methods must be different from the above two methods)-(void) scrollViewWillBeginDecelerating :( UIScrollView *) scrollView {NSLog (@ "scrollViewWillBeginDecelerating ");} // scrollview stop-(void) scrollViewDidEndDecelerating :( UIScrollView *) scrollView {NSLog (@ "scrollViewDidEndDecelerating ");}