Skip to content

Instantly share code, notes, and snippets.

#import <Foundation/Foundation.h>
@interface GalleryItem : NSObject
@property (nonatomic, strong) NSString *itemImage;
+ (instancetype)galleryItemWithDictionary:(NSDictionary *)dictionary;
@end
@IBAction func testAlert1() {
let controller = UIAlertController(title: "Error!", message: "Test error message", preferredStyle: .Alert)
let alertAction = UIAlertAction(title: "Dismiss", style: .Destructive) { (action) in
print("Dismiss button tapped!")
}
controller.addAction(alertAction)
presentViewController(controller, animated: true, completion: nil)
- (void)testAlert1:(id)sender
{
UIAlertController *controller = [UIAlertController alertControllerWithTitle:@"Error!"
message:@"Test error message"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *alertAction = [UIAlertAction actionWithTitle:@"Dismiss"
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *action) {
NSLog(@"Dismiss button tapped!");
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask {
if self.window?.rootViewController?.presentedViewController is SecondViewController {
let secondController = self.window!.rootViewController!.presentedViewController as! SecondViewController
if secondController.isPresented { // Check current controller state
return UIInterfaceOrientationMask.All;
} else {
return UIInterfaceOrientationMask.Portrait;
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if ([self.window.rootViewController.presentedViewController isKindOfClass:[SecondViewController class]])
{
SecondViewController *secondController = (SecondViewController *) self.window.rootViewController.presentedViewController;
if (secondController.isPresented) // Check current controller state
{
return UIInterfaceOrientationMaskAll;
}
class SecondViewController: UIViewController {
var isPresented = true // This property is very important, set it to true initially
@IBAction
func dismiss() {
isPresented = false // Set this flag to NO before dismissing controller, so that correct orientation will be chosen for the bottom controller
self.presentingViewController!.dismissViewControllerAnimated(true, completion: nil);
}
@interface SecondViewController ()
@property (nonatomic) BOOL isPresented; // This property is very important
@end
@implementation SecondViewController
- (void)viewDidLoad
{
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask {
if self.window?.rootViewController?.presentedViewController is SecondViewController {
return UIInterfaceOrientationMask.All;
} else {
return UIInterfaceOrientationMask.Portrait;
}
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if ([self.window.rootViewController.presentedViewController isKindOfClass:[SecondViewController class]])
{
return UIInterfaceOrientationMaskAll;
}
else return UIInterfaceOrientationMaskPortrait;
}
@interface RadiosPreferences : NSObject
@property (nonatomic) BOOL airplaneMode;
- (void)synchronize;
@end