Http://blog.sina.com.cn/s/articlelist_1935098904_1_1.html
, get the global delegate object so that we can invoke the methods and variables in this object:
[(myappdelegate*) [[UIApplication Sharedapplication] delegate] mymethodormyvariable];
2. Get the main bundle of the program:
NSBundle *bundle = [NSBundle mainbundle];
Bundles can be understood as a folder in which the content follows a specific framework.
One of the main uses of the main bundle is the use of resource files, slices, sounds, plst files, etc. in the program.
Nsurl *plisturl = [Bundle urlforresource:@ "Plistfile" withextension:@ "plist"];
The above code obtains the path to the Plistfile.plist file.
3. Play the Sound in the program:
First add Audiotoolbox to the program:
Next, add #import in the. M method that has the play sound method:
#import
Next, the code to play the sound is as follows:
NSString *path = [[NSBundle mainbundle] pathforresource:@ "Soundfilename" oftype:@ "wav"];
Systemsoundid Soundid;
Audioservicescreatesystemsoundid (__bridge cfurlref) [Nsurl Fileurlwithpath:path], &soundid);
Audioservicesplaysystemsound (Soundid);
4. Set and get property values in the class:
[Self setValue: Variable value forkey: variable name];
[Self valueforkey: variable name];
5. Let a method execute after a certain period of time in the future:
[Self Performselector: @selector (method name) Withobject:nil Afterdelay: Delay time (s)];
6. Get the device version number:
float Version = [[[Uidevice Currentdevice] systemversion] floatvalue];
7, the capture program closed or into the background event:
UIApplication *app = [UIApplication sharedapplication];
[[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (applicationwillresignactive:) Name: Uiapplicationwillresignactivenotification Object:app];
Applicationwillresignactive: Add the desired action in this method
8. Check the fonts supported by the device:
For (NSString *family in [Uifont Familynames]) {
NSLog (@ "%@", family);
For (NSString *font in [Uifont fontnamesforfamilyname:family]) {
NSLog (@ "\t%@", font);
}
}
9. Add a click event for Uiimageview:
imageview.userinteractionenabled = YES;
UITapGestureRecognizer *singletap = [[UITapGestureRecognizer alloc] initwithtarget:self action: @selector ( Yourhandlingcode:)];
[ImageView Addgesturerecognizer:singletap];
10, add multi-language support: such as image picker component, the text of the button above it changes with the device language environment, but first in the project to add language:
11, enable the program to support devices such as itunes, such as the use of PC-side tools to the program documents to drag and drop files.
12, the page switch effect settings:
Controller.modaltransitionstyle = uimodaltransitionstylecoververtical;
[Self Presentmodalviewcontroller:controller animated:yes];
The effects available for use:
Uimodaltransitionstylecoververtical
Uimodaltransitionstylefliphorizontal
Uimodaltransitionstylecrossdissolve
Uimodaltransitionstylepartialcurl
To restore the previous page:
[Self dismissmodalviewcontrolleranimated:yes];
iOS development: Tips accumulate 2