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 / 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 / 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 / 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 / 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 / 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 / file.m
Created August 20, 2014 10:03
iOS 8 push notification diff
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
[application registerUserNotificationSettings:
[UIUserNotificationSettings settingsForTypes:
(UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
@thoretton-edwin
thoretton-edwin / test.m
Created September 19, 2014 14:24
check and launch linkedIn app
BOOL linkedInIsInstalled =
[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"linkedin:#profile/9999"]];
if(linkedInIsInstalled)
{
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"linkedin:#profile/9999"]];
}
else
{
@thoretton-edwin
thoretton-edwin / duplicateSymbols.txt
Last active August 29, 2015 14:24
iOS common errors
=> Error :
duplicate simbols $viewController.variable in .o .....
=> Solution :
check import if .m is included
=> Source :
http://stackoverflow.com/questions/3231948/duplicate-symbol-issues
@thoretton-edwin
thoretton-edwin / GalleryImageViewCell.h
Last active April 7, 2016 12:18
Gallery with zoom & snap
@interface GalleryImageViewCell : UICollectionViewCell <UIScrollViewDelegate>
@property (weak, nonatomic) IBOutlet UIScrollView *scrollContainer;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *scrollHeightLayoutConstraint;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *scrollWidthLayoutConstraint;
@end
@thoretton-edwin
thoretton-edwin / Gitattributes for Xcode projects
Created May 19, 2017 12:33 — forked from kiero/Gitattributes for Xcode projects
.gitignore & .gitattributes for Xcode projects
# excludes this file from merges
# treats it like binary file
*.pbxproj -crlf -diff -merge