This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Portrait | |
- (NSUInteger)supportedInterfaceOrientations { | |
return UIInterfaceOrientationMaskPortrait; | |
} | |
// Landscape | |
- (NSUInteger)supportedInterfaceOrientations { | |
return UIInterfaceOrientationMaskLandscape; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Open | |
UIViewController *viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewControllerStoryboardID"]; | |
// Or (but no use Storyboard) | |
CustomViewController *viewController = [[CustomViewController alloc] init] | |
[self.navigationController pushViewController:viewController animated:YES]; | |
// Close | |
[self.navigationController popViewControllerAnimated:NO]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Read | |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
NSString *session = [defaults stringForKey:@"session"]; | |
// Write | |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
[defaults setObject:session forKey:@"session"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" | |
message:@"Message" | |
delegate:nil // o self | |
cancelButtonTitle:@"OK" | |
otherButtonTitles:nil]; | |
[alert show]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(BOOL) NSStringIsValidEmail:(NSString *)checkString { | |
BOOL stricterFilter = YES; // Discussion http://blog.logichigh.com/2010/09/02/validating-an-e-mail-address/ | |
NSString *stricterFilterString = @"[A-Z0-9a-z\\._%+-]+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2,4}"; | |
NSString *laxString = @".+@([A-Za-z0-9]+\\.)+[A-Za-z]{2}[A-Za-z]*"; | |
NSString *emailRegex = stricterFilter ? stricterFilterString : laxString; | |
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex]; | |
return [emailTest evaluateWithObject:checkString]; | |
} | |
// Others |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From Fragment | |
String[] myArray = getActivity().getResources().getStringArray(R.array.myarray); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Write | |
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); | |
SharedPreferences.Editor editor = settings.edit(); | |
editor.putBoolean("silentMode", mSilentMode); | |
editor.commit(); | |
// Read | |
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); | |
boolean silent = settings.getBoolean("silentMode", false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Solution | |
[NSString stringWithFormat:@"%@", string] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public boolean onKeyDown(int keyCode, KeyEvent event) { | |
if (keyCode == KeyEvent.KEYCODE_MENU) { | |
// MENU pressed | |
return true; | |
} | |
return super.onKeyDown(keyCode, event); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) { | |
SLComposeViewController *tweetSheetOBJ = [SLComposeViewController | |
composeViewControllerForServiceType:SLServiceTypeTwitter]; | |
[tweetSheetOBJ setInitialText:@"My tweet"]; | |
[self presentViewController:tweetSheetOBJ animated:YES completion:nil]; | |
} |