Basic Knowledge 3

Source: Internet
Author: User

How do I set the rotation point in quartz?
12 UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg.png"]]; imageView.layer.anchorPoint = CGPointMake(0.5, 1.0);

This is to set the rotation point to the bottom middle. Remember to be supported in Quartzcore.framework.

Create a. plist file and store it?
123456789101112131415161718 NSString *errorDesc;  //用来存放错误信息 NSMutableDictionary *rootObj = [NSMutableDictionary dictionaryWithCapacity:4]; //NSDictionary, NSData等文件可以直接转化为plist文件 NSDictionary *innerDict; NSString *name; Player *player; NSInteger saveIndex; for(int i = 0; i < [playerArray count]; i++) {       player = nil;       player = [playerArray objectAtIndex:i];       if(player == nil)              break;       name = player.playerName;// This “Player1″ denotes the player name could also be the computer name       innerDict = [self getAllNodeInfoToDictionary:player];       [rootObj setObject:innerDict forKey:name]; // This “Player1″ denotes the person who start this game } player = nil; NSData *plistData = [NSPropertyListSerialization dataFromPropertyList:(id)rootObj format:NSPropertyListXMLFormat_v1_0 errorDescription:&errorDesc];

The last 2 lines can be ignored, just add a little bit of content to rootobj. This plistdata to create a good plist file, with its WriteToFile method can be written as a file. Here's the code:

?
1234567891011121314151617 /*得到移动设备上的文件存放位置*/        NSString *documentsPath = [self getDocumentsDirectory];         NSString *savePath = [documentsPath stringByAppendingPathComponent:@"save.plist"];          /*存文件*/        if (plistData) {                 [plistData writeToFile:savePath atomically:YES];          }          else {                 NSLog(errorDesc);                 [errorDesc release];         }          - (NSString *)getDocumentsDirectory {                 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);                 return [paths objectAtIndex:0];         }
Read the plist file and convert it to nsdictionary?
123 NSString *documentsPath = [self getDocumentsDirectory]; NSString *fullPath = [documentsPath stringByAppendingPathComponent:@"save.plist"]; NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:fullPath];
Read a generic document file?
1234567891011121314151617 NSString *tmp; NSArray *lines; /*将文件转化为一行一行的*/lines = [[NSString    stringWithContentsOfFile:@"testFileReadLines.txt"]                componentsSeparatedByString:@”\n”];  NSEnumerator *nse = [lines objectEnumerator];  // 读取<>里的内容  while(tmp = [nse nextObject]) {           NSString *stringBetweenBrackets = nil;           NSScanner *scanner = [NSScanner scannerWithString:tmp];           [scanner scanUpToString:@"<" intoString:nil];           [scanner scanString:@"<" intoString:nil];           [scanner scanUpToString:@">" intoString:&stringBetweenBrackets];           NSLog([stringBetweenBrackets description]);   }

For read-write files, there are additional, temporarily to this. Random numbers and file reads and writes are often used in game development. So put part of the content here, in order to share with you, also when the record, easy to find.

Hide Navigationbar?
1 [self.navigationController setNavigationBarHidden:YES animated:YES];

You can use it in a viewcontroller that you want to hide.

Basic Knowledge 3

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.