IPhoneThe Application Development Study Notes are described in this article.IphoneHow to read txtFileUse WebView to implement scrolling paging effect on ipad,IPhoneThe content of the screenshot program.
Iphone reads txt files
Read general document files
- NSString * tmp;
- NSArray * lines;
- Lines = [[NSString stringWithContentsOfFile: @ "testFileReadLines.txt"]
- ComponentsSeparatedByString: @ "\ n"];
-
- NSEnumerator * neuron = [lines objectEnumerator];
-
- // Read the content in <>
- While (tmp = [neuron nextObject]) {
- NSString * stringBetweenBrackets = nil;
- Ns‑* token = [ns‑scannerwithstring: tmp];
- [Export scanUpToString: @ "<" Export string: nil];
- [Export scanString: @ "<" Export string: nil];
- [Export scanUpToString: @ ">" Export string: & stringBetweenBrackets];
-
- NSLog ([stringBetweenBrackets description]);
- }
Use WebView to implement scrolling paging effect on ipad
Web pages in WebView are smoothly rolled by default during scrolling. If you want to implement paging scrolling, what should you do?
By default, UIWebView is not provided by APIs. However, in sdk3.2, its first sub-View is UIScrollView. Note that for versions earlier than 3.2, UIScroller is private and undisclosed, I have not studied how to set this ).
The code is relatively simple:
- int height = webView.frame.size.height;
-
- NSString *html = [NSString stringWithFormat:@"
- }
- </style>
- </div><div style='background-color:#FFFF00;'></div><div style='background-color:#FF00FF;'>
- </div><div style='background-color:#0000FF;'></div><div style='background-color:#00FFFF;'>
- </div><div style='background-color:#00FF00;'></div></body>
- height];
-
- [webView loadHTMLString:html baseURL:nil];
- UIScrollView *scrollView = [webView.subviews objectAtIndex:0]; // it is "UIScroller" on iphone(v3.1.3-)
- if (scrollView && [scrollView isKindOfClass:[UIScrollView class]]) {
- scrollView.pagingEnabled = YES;
- }
IPhone image capture program
// ObtainScreenImage
- - (UIImage *)imageFromView: (UIView *) theView
- {
-
- UIGraphicsBeginImageContext(theView.frame.size);
- CGContextRef context = UIGraphicsGetCurrentContext();
- [theView.layer renderInContext:context];
- UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
-
- return theImage;
- }
// ObtainScreenImage
- - (UIImage *)imageFromView: (UIView *) theView atFrame:(CGRect)r
- {
- UIGraphicsBeginImageContext(theView.frame.size);
- CGContextRef context = UIGraphicsGetCurrentContext();
- CGContextSaveGState(context);
- UIRectClip(r);
- [theView.layer renderInContext:context];
- UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
-
- return theImage;//[self getImageAreaFromImage:theImage atFrame:r];
- }
Summary:IPhoneThe content of the Application Development Study Notes has been introduced. I hope this article will help you!