Skip to content

Instantly share code, notes, and snippets.

View thoretton-edwin's full-sized avatar

Edwin Thoretton thoretton-edwin

  • Slate Digital France
  • Grenoble
View GitHub Profile
@thoretton-edwin
thoretton-edwin / file.m
Created August 20, 2014 10:02
iOS 8 location manager diff
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
[locationManager requestAlwaysAuthorization];
}
// auth needed before start method
[locationManager startUpdatingLocation];
// in plist file : (Boolean value) NSLocationAlwaysUsageDescription : YES
@thoretton-edwin
thoretton-edwin / size.java
Created July 11, 2014 14:32
Android get screen size
int screenWidth = 0;
int screenHeight = 0;
if(android.os.Build.VERSION.SDK_INT < 10) {
Display display = getWindowManager().getDefaultDisplay();
screenWidth = display.getWidth();
screenHeight = display.getHeight();
} else {
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
screenWidth = metrics.heightPixels;
@thoretton-edwin
thoretton-edwin / example.m
Created June 30, 2014 09:45
iOS check platform version
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
// Load resources for iOS 6.1 or earlier
} else {
// Load resources for iOS 7 or later
}
@thoretton-edwin
thoretton-edwin / fragment.java
Last active August 29, 2015 13:59 — forked from mpaloulack/gist:10472674
Android remplacer un fragment
Fragment frag;
//ajout d'un fragment
TonFragment newFragment = new TonFragment();
android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.add(R.id.fragment_container, newFragment).addToBackStack("A_B_TAG");
transaction.commit();
//remplacement d'un fragment
@thoretton-edwin
thoretton-edwin / module.m
Created March 12, 2014 14:29
get iOS language settings
NSString * language = [[NSLocale preferredLanguages] objectAtIndex:0];
if([language isEqualToString:@"fr"]){//...}
@thoretton-edwin
thoretton-edwin / instruction.txt
Created March 9, 2014 11:13
iOS add custom font
In plist file :
1) add "Fonts provided by application" item in property list
2) drag the .ttf or .otf file in supporting file folder
Warning ! check case "add target"
3) add string item in Fonts provided by application array : example "myFont.ttf"
4) in the module :
@thoretton-edwin
thoretton-edwin / background.m
Created February 20, 2014 09:45
iOS edit background view with UIImage
//Background design
UIGraphicsBeginImageContext(self.view.frame.size);
[[UIImage imageNamed:@"appBackground.png"] drawInRect:self.view.bounds];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
self.view.backgroundColor = [UIColor colorWithPatternImage:image];
@thoretton-edwin
thoretton-edwin / dialog.java
Created February 18, 2014 07:08
Android progress dialog
wait = new ProgressDialog(this);
wait.show(this, « titre", " message ");
wait.dismiss();
@thoretton-edwin
thoretton-edwin / example.m
Created February 17, 2014 16:04
iOS Push second view controller : PresentViewController,UIViewController
// to push, add in the UIViewController :
MyUIViewController *second = [[LoginUIViewController alloc] initWithNibName:nil bundle:nil];
[self presentViewController:second animated:YES completion:nil];
// in the second view controller add
[self dismissViewControllerAnimated:YES completion:nil];
@thoretton-edwin
thoretton-edwin / module.m
Last active August 29, 2015 13:56
iOS NSDictionary allocation and init
NSDictionary* dico=[[NSDictionary alloc]init];
dico = [NSDictionary
dictionaryWithObjects:@[@"http://www.google.com/favicon.ico",@"google",@"http://www.google.com"]
forKeys:@[@"favicon",@"nom",@"url"]];