First, the database operation
1 Create
The CREATE table IF not EXISTS table name (field 1 type 1 modifier, field 2 type 2)
The INTEGER PRIMARY key autoincrement means to try this field as the primary key
(see Fmdbdemo later)
2 Increase
3 Delete
4 modifications
5 queries (not involving database content or structural changes)
Second, sandbox and path acquisition
/users/sunli/library/developer/coresimulator/devices/073756a6-6159-4084-ad68-05029d3e9b04/data/containers/data /application/c536edf0-b85d-4790-abd1-26a8eb7ac1e8/documents
/users/sunli/library/developer/coresimulator/devices/073756a6-6159-4084-ad68-05029d3e9b04/data/containers/data /application/c536edf0-b85d-4790-abd1-26a8eb7ac1e8
Documents: User data in the app can be placed here, itunes Backup and restore will include this directory
TMP: Store temporary files, itunes does not back up and restore this directory, files in this directory may be deleted after the app exits
Library/caches: Store cached files, itunes does not back up this directory, files in this directory will not be deleted in the app exit
TMP directory
Nshomedirectory ()
This is the parent directory of documents, and of course the parent directory of the TMP directory. Then the file path can be written like this:
NSString *filename=[nshomedirectory () stringbyappendingpathcomponent:@ "Tmp/myfile.txt"];
Or use this function:
Nstemporarydirectory ()
Screen fit
Iphone
It is obvious that the size aspect ratio of the three screens is similar, so you can scale up to 6 and 6Plus on a 5 basis.
In the AppDelegate.h
@property float Autosizescalex;
@property float Autosizescaley;
In the APPDELEGATE.M
#define ScreenHeight [[UIScreen mainscreen] bounds].size.height//get screen height, compatibility test
#define SCREENWIDTH [[UIScreen mainscreen] bounds].size.width//get screen width, compatibility test
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions {
Appdelegate *mydelegate = [[UIApplication sharedapplication] delegate];
if (ScreenHeight > 480) {
Mydelegate.autosizescalex = screenwidth/320;
Mydelegate.autosizescaley = screenheight/568;
}else{
Mydelegate.autosizescalex = 1.0;
Mydelegate.autosizescaley = 1.0;
}
}
Because the height of the iphone4s screen is 480, when the screen size is greater than iPhone4, Autosizescalex and Autosizescaley are the aspect ratios of the current screen and iPhone5 dimensions. Like what
If it is 5,autosizescalex=1,autosizescaley=1;
If it is 6,autosizescalex=1.171875,autosizescaley=1.17429577;
If it is 6plus,autosizescalex=1.29375,autosizescaley=1.2957;
Now that we have the proportional relationship, let's take a look at how to solve the code-setting interface compatibility.
CGRectMake (CGFloat x, cgfloat y, cgfloat width, cgfloat height) This method makes it common for us to set the size of the method, and now I set up a method similar to this one.
In the. m file
UIButton *btn = [[UIButton alloc] initwithframe:cgrectmake1 (100, 100, 50, 50)];
Cg_inline cgrect//Note: The code here should be placed at the bottom of the. m file
CGRectMake1 (CGFloat x, cgfloat y, cgfloat width, cgfloat height)
{
Appdelegate *mydelegate = [[UIApplication sharedapplication] delegate];
CGRect rect;
rect.origin.x = x * MYDELEGATE.AUTOSIZESCALEX; RECT.ORIGIN.Y = y * Mydelegate.autosizescaley;
Rect.size.width = width * MYDELEGATE.AUTOSIZESCALEX; Rect.size.height = height * Mydelegate.autosizescaley;
return rect;
}
Lan Yi Education Database & screen adaptation