IOS _ knowledge above 10 k monthly salary

Source: Internet
Author: User

1. Obtain the system language settings NSUserDefaults * userDefault = [NSUserDefaults standardUserDefaults]; NSArray * ages = [userDefault objectForKey: @ "AppleLanguages"]; NSString * preferredLang = [ages objectAtIndex: 0]; 2 file size in the cache path-(unsigned long int) cacheFolderSize {NSFileManager * _ manager = [NSFileManager defaultManager]; NSArray * _ cachePaths = NSSearchPathForDirectoriesInDomains (NSCachesDirectory, NSUserDoma InMask, YES); NSString * _ cacheDirectory = [_ cachePaths objectAtIndex:]; NSArray * _ cacheFileList; NSEnumerator * _ handler; NSString * _ cacheFilePath; unsigned long int _ cacheFolderSize =; _ cacheFileList = [_ manager subpathsAtPath: _ cacheDirectory]; _ cacheEnumerator = [_ cacheFileList objectEnumerator]; while (_ cacheFilePath = [_ Your nextObject]) {NSDictionary * _ folder Butes = [_ managerfileAttributesAtPath: [_ cacheDirectory paths: _ cacheFilePath] traverseLink: YES]; _ cacheFolderSize + = [_ cacheFileAttributes fileSize];} // return _ cacheFolderSize in bytes ;} 3 when Popover pushes, the Frame cannot be changed. The solution is implemented in ViewController of popover:-(void) viewWillAppear :( BOOL) animated {CGSize size = CGSizeMake (320,480 ); // size of view in popover self. contentSizeForViewInPopov Er = size; [super viewWillAppear: animated];} 4tableview sliding causes NSTimer and delegate callback to stop solution // request callback NSURLRequest * request =... scheduleInRunLoop: [nsunloop currentRunLoop] forMode: Unknown] [connection start] // timer callback nstmer * updateTimer = [NSTimer failed: 0.01f objective: self-selection: Select (updatePencent) UserInfo: no duplicates: Yes]; * The main value of the nsnsunloop is [nsunloop currentRunLoop] [main addTimer: updateTimer forMode: nsunloopcom MonModes]; 5. The UIGestureRecognizer6SFHFKeychainUtils class stores information. Password protection is provided by the apple SDK, which is easy to use as follows: 1. Introduce the Security. frameWork. 2. Introduce the header file SFHKeychainUtils. h.3. Password: [SFHFKeychainUtils storeUsername: @ "dd" andPassword: @ "aa" forServiceName: Unknown: 1 error: nil]; [SFHFKeychainUtils deleteItemForUsername: @ "dd" andServiceName: SERVICE_NAME error: nil]; 4. passWord: NSString * passWord = [SFHFKeychainUtils getPasswordForUsername: @ "dd" andServiceName: SERVICE_NAMEerror: nil]; 7 missing required architecture i386 in file solution on TargetInfo Modify the Framework Search Pasths to delete the content. 8 view zoom in and out the animation effect // create the scaled out view myWeiBoImageVC = [[UIViewController alloc] init]; myWeiBoImageVC. view. clipsToBounds = YES; myWeiBoImageVC. view. alpha = 0.0; myWeiBoImageVC. view. frame = CGRectMake (64, 0, 1024-64,768-20); [self. view addSubview: myWeiBoImageVC. view]; CGAffineTransform newTransform = CGAffineTransformScale (myWeiBoImageVC. view. transform, 0.1, 0.1); [myWeiBoImageVC. view setTransform: newTransform]; myWe IBoImageVC. view. center = CGPointMake (670,100); [self initialize mselector: @ selector (imageViewControllerBigAnimation)]; // enlarge the created and reduced view-(void) imageViewControllerBigAnimation {[UIView beginAnimations: @ "imageViewBig" context: nil]; [UIView setAnimationDuration: 0.5]; CGAffineTransform newTransform = CGAffineTransformConcat (myWeiBoImageVC. view. transform, CGAffineTransformInvert (myWeiBoImageVC. view. transform) ); [MyWeiBoImageVC. view setTransform: newTransform]; myWeiBoImageVC. view. alpha = 1.0; myWeiBoImageVC. view. center = CGPointMake (416,510); [UIView commitAnimations];} // zoom out view hiding-(void) imageViewControllerSmallAnimation {[UIView beginAnimations: @ "imageViewSmall" context: nil]; [UIView setAnimationDuration: 0.5]; CGAffineTransform newTransform = CGAffineTransformScale (myWeiBoImageVC. view. transform, 0.1, 0.1); [myWeiBoImageVC. view setTransform: newTransform]; myWeiBoImageVC. view. center = CGPointMake (670,100); [UIView finished];} 9 UIScrollView controls View scaling allImageScrollView = [[UIScrollView alloc] initWithFrame: CGRectMake (0, 0,768,102 4)]; allImageScrollView. minimumZoomScale = 0.3; allImageScrollView. maximumZoomScale = 1.0; allImageScrollView. backgroundColor = [UIColor clearColor]; allImageScrollV Iew. delegate = self; [self. view addSubview: allImageScrollView]; mPicStatusesViewController = [[PicStatusesViewController alloc] init]; [allImageScrollView addSubview: mPicStatusesViewController. view]; // UIScrollView Delegete implementation-(UIView *) viewForZoomingInScrollView :( UIScrollView *) scrollView {return mPicStatusesViewController. view; // return the view to be scaled added on ScrollView}-(void) scrollViewDidZoom :( UIScrollView *) scr OllView {// called in scaling operation}-(void) scrollViewDidEndZooming :( UIScrollView *) scrollView withView :( UIView *) view atScale :( float) scale {// called after scaling} 10. Playing video NSString * urlString = [NSString stringWithString: @ "video url"]; NSURL * movieUrl = [[NSURL alloc] initWithString: urlString]; MPMoviePlayerController * myMoviePlayer = [[MPMoviePlayerController alloc] initWithContentURL: movieUrl]; myMoviePlayer. view. frame = CGRectMake (250,250,350,350); [self. view addSubview: myMoviePlayer. view]; myMoviePlayer. shouldAutoplay = YES; myMoviePlayer. scalingMode = animated; [myMoviePlayer play]; 11. Google Maps play the animation effect CATransition * animation = [CATransition animation]; [animation setDelegate: self]; [animation setDuration: 0.35]; [animation setTimingFunction: UIViewAnimationCurveEaseInOut]; if (! Curled) {animation. type = @ "pageCurl"; animation. fillMode = kCAFillModeForwards; animation. endProgress = 0.40;} else {animation. type = @ "pageUnCurl"; animation. fillMode = kCAFillModeBackwards; animation. startProgress = 0.30;} [animation setRemovedOnCompletion: NO]; [self. view exchangeSubviewAtIndex: 0 withSubviewAtIndex: 1]; [self. view. layer addAnimation: animation forKey: @ "pageCurlAnimation"]; 12. Iew: Add shadow and border UIImageView * imgvPhoto = [UIImageView alloc] init]; // Add the border CALayer * layer = [_ imgvPhoto layer]; layer. borderColor = [[UIColor whiteColor] CGColor]; layer. borderWidth = 5.0f; // Add four side shadow _ imgvPhoto. layer. shadowColor = [UIColor blackColor]. CGColor; _ imgvPhoto. layer. shadowOffset = CGSizeMake (0, 0); _ imgvPhoto. layer. shadowOpacity = 0.5; _ imgvPhoto. layer. shadowRadius = 10.0; // Add two side shadow _ imgvPhoto. Layer. shadowColor = [UIColor blackColor]. CGColor; _ imgvPhoto. layer. shadowOffset = CGSizeMake (4, 4); _ imgvPhoto. layer. shadowOpacity = 0.5; _ imgvPhoto. layer. shadowRadius = 2.0; 13. Add an image and a timer to the viewDidLoad event using NSTimer and UIView animation and start the event. The pic here should be defined in the header file. -(Void) viewDidLoad {[super viewDidLoad]; self. pic = [UIImage imageNamed: @ "snow.png"]; // initialize the image // start the timer to achieve the snow effect [nst?scheduledtimerwithtimeinterval :( 0.2) target: self selector: @ selector (ontime) userInfo: nil repeats: YES];} and then implement the ontime method scheduled by the Timer:-(void) ontime {UIImageView * view = [[UIImageView alloc] initWithImage: pic]; // declare a UIImageView object to add an image view. alpha = 0.5; // set the alpha of the view to 0.5, and the translucent int x = round (r Andom () 20); // obtain the x coordinate int y = round (random () 20) of the image at random ); // This is the int s = round (random () + 10 of the final coordinate X axis of the image; // This defines the snowflake image size int sp = 1/round (random () 0) + 1; // This is the speed view. frame = CGRectMake (x,-50, s, s); // the size and position of the snowflake starting from [self. view addSubview: view]; // Add this view [UIView beginAnimations: nil context: view]; // start the animation [UIView setAnimationDuration: 10 * sp]; // set the speed view. frame = CGRectMake (y, 500, s, s); // sets the final Disappearance coordinate of the snowflake [UIView setAnima TionDelegate: self]; [UIView commitAnimations];} 14. Configure Xcode to view program crash information. 1. Find Executables in the left-side directory of xcode to open 2. Double-click the file with the same name as the project. 3. In the Arguments option of the open file, add Name: NSZombieEnabled in the following box to set value to YES. 15. Send emails in the program and check whether the email address of the device is configured.-(void) addEmail {Class mailClass = (NSClassFromString (@ "MFMailComposeViewController"); if (mailClass! = Nil) {if ([mailClass canSendMail]) {[self displayComposerSheet];} else {[self launchMailAppOnDevice] ;}} else {[self launchMailAppOnDevice] ;}}-(void) displayComposerSheet {MFMailComposeViewController * controller = [[MFMailComposeViewController alloc] init]; controller. navigationBar. tag = 1002; [self. navigationController. navigationBar setNeedsDisplay]; controller. mailComposeDelegate = self; [controller SetSubject: @ "feedback"]; [controller setToRecipients: [[NSArray alloc] initWithObjects: @ "555@cifco.net.cn", nil]; NSString * emailBody = nil; [controller setMessageBody: emailBody isHTML: YES]; [self presentModalViewController: controller animated: YES]; [controller release] ;}# pragma mark ~----- (void) mailComposeController :( MFMailComposeViewController *) controller then :( MFMailCom PoseResult) result error :( NSError *) error {if (result = MFMailComposeResultSent) {[self defined: YES];} if (result = MFMailComposeResultSaved) {[self defined: YES];} if (result = MFMailComposeResultFailed) {Emailalert = [[UIAlertView alloc] initWithTitle: @ "" message: @ "failed to send" delegate: selfcancelButtonTitle: @ "understand" otherButtonTitles: nil]; [Emailalert s How];} if (result = MFMailComposeResultCancelled) {[self defined: YES];}-(void) alertView :( UIAlertView *) alertView clickedButtonAtIndex :( NSInteger) buttonIndex {if (alertView = Emailalert) {if (buttonIndex =) {[self dismissModalViewControllerAnimated: YES] ;}} else {if (buttonIndex =) {// [self dismissModalViewControllerAnimated: YES];} else {NSString * recipients = @ "mailto: t Heonelgq@gmail.com? Cc = theone_liuguoqing@163.com & subject = text "; NSString * body = @" & body = text! "; NSString * email = [NSString stringWithFormat: @" % @ ", recipients, body]; email = [email token: NSUTF8StringEncoding]; [[UIApplication sharedApplication] openURL: [NSURL URLWithString: email] ;}}# pragma mark-# pragma mark Workaround-(void) launchMailAppOnDevice {isEmailalert = [[UIAlertView alloc] initWithTitle: @ "warning" message: @ "Please configure your mailbox" delegate: selfcancelButtonTitle :@ "Cancel" otherButtonTitles: @ "OK", nil]; [isEmailalert show];} 16. Program startup screen size iOS devices now have three different resolutions: iPhone 320x480, iPhone 4 640x960, and iPad 768x1024. In the past, you only needed to prepare a Default.png startup screen (image), but now it is much more complicated. The following is a summary of CocoaChina members. If a program supports both iPhone and iPad, it must contain the following images: default-Portrait.png iPad dedicated vertical Start Screen 768x1024213768x1004default-landscape.png iPad dedicated horizontal Start Screen iPad dedicated vertical Start Screen (Home button on the screen), can be omitted iPad dedicated horizontal Start screen, you can omit the 1024x7682131024x748default-landscaperight.png iPad-specific horizontal Start Screen. You can omit the 1024x7682131024x748default.png iPhone default start picture. Continue (not recommended) 320x480116320x460default@2x.png iPhone4 Boot Image 640x960 or 640x920 to use the above boot screen on iPad, you also need to add key: UISupportedInterfaceOrientations in info. plist. At the same time, add the value UIInterfaceOrientationPortrait, restart, resume, and ASIHTTPRequest to implement the resumable download-(IBAction) URLFetchWithProgress :( id) sender {[startButton setTitle: @ "Stop" forState: uicontrol [startButton addTarget: self action: @ selector (stopURLFetchWithProgress :) forControlEvents: UIControlEventTouchUpInside]; NSSt Ring * tempFile = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent: @ "dependencies"]; if ([[NSFileManager defamanager] fileExistsAtPath: tempFile]) {[NSFileManager defaultManager] removeItemAtPath: tempFile error: nil];} [self failed: self];}-(IBAction) stopURLFetchWithProgress :( id) sender {networkQueue = [[ASINetwo RkQueue alloc] init]; timer = [NSTimer scheduledTimerWithTimeInterval: 1.0 target: selfselector: @ selector (timer) userInfo: nil repeats: YES]; timer = nil; [startButton setTitle: @ "Stop" forState: UIControlStateNormal]; [startButton addTarget: self action: @ selector (role :) forControlEvents: UIControlEventTouchUpInside]; [networkQueue cancelAllOperations]; [resumeButton setEn Abled: YES];}-(IBAction) identifier :( id) sender {[resumeButton setEnabled: NO]; [startButton setTitle: @ "Start" forState: UIControlStateNormal]; [startButton addTarget: self action: @ selector (handler :) forControlEvents: UIControlEventTouchUpInside]; [networkQueue cancelAllOperations]; [networkQueue setShowAccurateProgress: YES]; [networkQueue setDownloadProgressDelegate: progress Indicator]; [networkQueue setDelegate: self]; [networkQueue progress: @ selector (Progress :)]; ASIHTTPRequest * request = [[[ASIHTTPRequest alloc] initWithURL: [NSURLURLWithString: @ "http://9991.net/blog/mp3/2.mp3"] autorelease]; [request setDownloadDestinationPath: [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent: @ "Meme XTrails_1.0b1.mp3 "]; [request setTemporaryFileDownloadPath: [[[NSBundle mainBundle] bundlePath] character: @" character "]; [request condition: YES]; [networkQueue addOperation: request]; [networkQueue go];}-(void) URLFetchWithProgressComplete :( ASIHTTPRequest *) request {if ([request error]) {fileLocation. text = [NSSt Ring stringWithFormat: @ "An error occurred: % @", [[[requesterror] userInfo] objectForKey: @ "Title"];} else {fileLocation. text = [NSString stringWithFormat: @ "File downloaded to % @", [requestdownloadDestinationPath];} [startButton setTitle: @ "Start" forState: UIControlStateNormal]; [startButton addTarget: self action: @ selector (URLFetchWithProgress :) forControlEvents: UIControlEventTouchUpInside];}-(IBAction) th RottleBandwidth :( id) sender {if ([(UIButton *) sender state] = YES) {[ASIHTTPRequest failed: Failed];} else {[ASIHTTPRequest setMaxBandwidthPerSecond:];} 18. Safari starts a local app and adds the URL types structure to the plist file. For example, enter the set string in the address bar of Safari. For example, QQ is set, and QQ is entered in the address bar: // you can start a local application. 19. solution to the conflict between the drag-to-video progress and the sliding gesture # pragma mark-# pragma mark transfer-(BOOL) gestureRecognizer :( optional *) gestureRecognizer shouldReceiveTouch :( UITouch *) touch {UIView * touchView = touch. view; if ([touchView isKindOfClass: [UISlider class]) {return NO;} else {return YES ;}} 20. method for creating and saving a Cookie NSString * cookieString = [NSString stringWithString: [headers objectForKey: @ "Cookie"]; N SMutableDictionary * cookieProperties = [[NSMutableDictionary alloc] init]; [cookieProperties setValue: cookieString forKey: Keys]; [cookieProperties setValue: @ "QQCookie" forKey: Keys]; [cookieProperties setValue: @ ".QQ.com" forKey: NSHTTPCookieDomain]; [cookieProperties setValue: [NSDate dateWithTimeIntervalSinceNow: 60*60] forKey: NSHTTPCookieExpires]; [cookieProperties setValue: @ "/" ForKey: NSHTTPCookiePath]; NSHTTPCookie * newcookie = [[NSHTTPCookie alloc] initWithProperties: cookieProperties]; [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie: newcookie] 21. Solution to popover horizontal and vertical screen position change 1. Processing in delegate-(void) done :( UIPopoverController *) popoverController {userImageShow = NO; if ([popoverController isEqual: myPopover]) {[mypover release]; myPopove R = nil;} 2. Popoverif (myPopover) {if (self. interfaceOrientation = UIInterfaceOrientationLandscapeLeft) | (self. interfaceOrientation = UIInterfaceOrientationLandscapeRight) {[myPopover presentpoverfromrect: CGRectMake (10,180, 1, 1) inView: self. view permittedArrowDirections ctions: UIPopoverArrowDirectionRight animated: YES];} else {[myPopover presentpoverfromrect: CGRectMake (20,180, 1, 1) inView: self. view permittedArrowDirections ctions: UIPopoverArrowDirectionRight animated: YES] ;}22. plist key values meaning Original: http://www.minroad.com /? P = 434 UIRequiresPersistentWiFi in the program pop up the key of the wifi selection (the wifi prompt needs to be turned on in the system settings) UIAppFonts embedded fonts font (http://www.minroad.com /? P = 412 for details) whether the UIApplicationExitsOnSuspend program is running in the background. It is silly to exit (0) when you enter the background, for details, refer to the background description of iOS4: UIDeviceFamily array type (1 for iPhone and iPod touch devices, 2 for iPad) UIFileSharingEnabled enabled enable the itunes shared document folder UILaunchImageFile, which is equivalent to default.png (renamed only) whether the UIPrerenderedIcon icon has the features required by the high-gloss UIRequiredDeviceCapabilities device (click here for details) UIStatusBarHidden State Bar Hidden (and the program area is displayed in default.png) UIStatusBarStyle: whether to enable the anti-sawtooth CFBundleDisplayName app display name CFBundleIconFile and CFBundleIconFiles. The difference between the CFBundleDisplayName and CFBundleDisplayName is that it is a short name and the custom url of the CFBundleVersion, the localized language used to use the url bounce program CFBundleLocalizations for local resources. It is used to display the local language CFBundleDevelopmentRegion in the lower left corner of the itunes page. If the user's location does not have the corresponding language resources, the value of this key is used as the final attachment of the official document by default. All the keys are available. The original English version is the correct path. :) click I will enter 24. add multiple targets in the xcode project.

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.