From 0908f921257868932d0efd08777686c14b2dfa57 Mon Sep 17 00:00:00 2001 From: Antol Date: Tue, 23 Sep 2014 17:45:37 +0400 Subject: [PATCH] Example of issue with presented view controller --- .../project.pbxproj | 6 ++ .../ModalViewController.h | 13 ++++ .../ModalViewController.m | 69 +++++++++++++++++++ .../RootViewController.m | 13 ++++ 4 files changed, 101 insertions(+) create mode 100644 REComposeViewControllerExample/REComposeViewControllerExample/ModalViewController.h create mode 100644 REComposeViewControllerExample/REComposeViewControllerExample/ModalViewController.m diff --git a/REComposeViewControllerExample/REComposeViewControllerExample.xcodeproj/project.pbxproj b/REComposeViewControllerExample/REComposeViewControllerExample.xcodeproj/project.pbxproj index 2fc6e11..0b57ea7 100644 --- a/REComposeViewControllerExample/REComposeViewControllerExample.xcodeproj/project.pbxproj +++ b/REComposeViewControllerExample/REComposeViewControllerExample.xcodeproj/project.pbxproj @@ -28,6 +28,7 @@ 30554D26163255070069220E /* foursquare-logo@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 30554D25163255070069220E /* foursquare-logo@2x.png */; }; 30B35CF517E54C820082CE0E /* RECommonFunctions.m in Sources */ = {isa = PBXBuildFile; fileRef = 30B35CF417E54C820082CE0E /* RECommonFunctions.m */; }; 30FD6D641631F8550017516D /* REComposeViewController.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 30FD6D631631F8550017516D /* REComposeViewController.bundle */; }; + 35F504ED19D1AEAB00A295DC /* ModalViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 35F504EC19D1AEAB00A295DC /* ModalViewController.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -63,6 +64,8 @@ 30B35CF317E54C820082CE0E /* RECommonFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RECommonFunctions.h; sourceTree = ""; }; 30B35CF417E54C820082CE0E /* RECommonFunctions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RECommonFunctions.m; sourceTree = ""; }; 30FD6D631631F8550017516D /* REComposeViewController.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = REComposeViewController.bundle; sourceTree = ""; }; + 35F504EB19D1AEAB00A295DC /* ModalViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModalViewController.h; sourceTree = ""; }; + 35F504EC19D1AEAB00A295DC /* ModalViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ModalViewController.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -117,6 +120,8 @@ 30118CEC1631D1D200B82F14 /* RootViewController.h */, 30118CED1631D1D200B82F14 /* RootViewController.m */, 30118CD21631D0DD00B82F14 /* Supporting Files */, + 35F504EB19D1AEAB00A295DC /* ModalViewController.h */, + 35F504EC19D1AEAB00A295DC /* ModalViewController.m */, ); path = REComposeViewControllerExample; sourceTree = ""; @@ -230,6 +235,7 @@ files = ( 30118CD81631D0DD00B82F14 /* main.m in Sources */, 30B35CF517E54C820082CE0E /* RECommonFunctions.m in Sources */, + 35F504ED19D1AEAB00A295DC /* ModalViewController.m in Sources */, 30118CDC1631D0DD00B82F14 /* AppDelegate.m in Sources */, 30118CEB1631D18A00B82F14 /* REComposeViewController.m in Sources */, 30118CEE1631D1D200B82F14 /* RootViewController.m in Sources */, diff --git a/REComposeViewControllerExample/REComposeViewControllerExample/ModalViewController.h b/REComposeViewControllerExample/REComposeViewControllerExample/ModalViewController.h new file mode 100644 index 0000000..ac122d6 --- /dev/null +++ b/REComposeViewControllerExample/REComposeViewControllerExample/ModalViewController.h @@ -0,0 +1,13 @@ +// +// ModalViewController.h +// REComposeViewControllerExample +// +// Created by Antol Peshkov on 23.09.14. +// Copyright (c) 2014 Roman Efimov. All rights reserved. +// + +#import + +@interface ModalViewController : UIViewController + +@end diff --git a/REComposeViewControllerExample/REComposeViewControllerExample/ModalViewController.m b/REComposeViewControllerExample/REComposeViewControllerExample/ModalViewController.m new file mode 100644 index 0000000..d588fee --- /dev/null +++ b/REComposeViewControllerExample/REComposeViewControllerExample/ModalViewController.m @@ -0,0 +1,69 @@ +// +// ModalViewController.m +// REComposeViewControllerExample +// +// Created by Antol Peshkov on 23.09.14. +// Copyright (c) 2014 Roman Efimov. All rights reserved. +// + +#import "ModalViewController.h" +#import "REComposeViewController.h" + +@interface ModalViewController () + +@end + +@implementation ModalViewController + +- (void)viewDidLoad +{ + [super viewDidLoad]; + self.view.backgroundColor = [UIColor lightGrayColor]; + + UIButton *socialExampleButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; + socialExampleButton.frame = CGRectMake((self.view.frame.size.width - 200) / 2.0f, 140, 200, 40); + socialExampleButton.autoresizingMask = UIViewAutoresizingFlexibleWidth; + [socialExampleButton addTarget:self action:@selector(socialExampleButtonPressed) forControlEvents:UIControlEventTouchUpInside]; + [socialExampleButton setTitle:@"Some social network" forState:UIControlStateNormal]; + [self.view addSubview:socialExampleButton]; + + UIButton *backButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; + backButton.frame = CGRectMake((self.view.frame.size.width - 200) / 2.0f, 170, 200, 40); + backButton.autoresizingMask = UIViewAutoresizingFlexibleWidth; + [backButton addTarget:self action:@selector(backButtonPressed) forControlEvents:UIControlEventTouchUpInside]; + [backButton setTitle:@"< Back" forState:UIControlStateNormal]; + [self.view addSubview:backButton]; +} + +- (void)socialExampleButtonPressed +{ + REComposeViewController *composeViewController = [[REComposeViewController alloc] init]; + composeViewController.title = @"Social Network"; + composeViewController.hasAttachment = YES; + composeViewController.delegate = self; + composeViewController.text = @"Test"; + [composeViewController presentFromRootViewController]; +} + +- (void)backButtonPressed +{ + [self dismissViewControllerAnimated:YES completion:nil]; +} + +#pragma mark - +#pragma mark REComposeViewControllerDelegate + +- (void)composeViewController:(REComposeViewController *)composeViewController didFinishWithResult:(REComposeResult)result +{ + [composeViewController dismissViewControllerAnimated:YES completion:nil]; + + if (result == REComposeResultCancelled) { + NSLog(@"Cancelled"); + } + + if (result == REComposeResultPosted) { + NSLog(@"Text: %@", composeViewController.text); + } +} + +@end diff --git a/REComposeViewControllerExample/REComposeViewControllerExample/RootViewController.m b/REComposeViewControllerExample/REComposeViewControllerExample/RootViewController.m index fe4de28..cfbb821 100644 --- a/REComposeViewControllerExample/REComposeViewControllerExample/RootViewController.m +++ b/REComposeViewControllerExample/REComposeViewControllerExample/RootViewController.m @@ -8,6 +8,7 @@ #import "RootViewController.h" #import "REComposeViewController.h" +#import "ModalViewController.h" @interface RootViewController () @@ -47,6 +48,13 @@ - (void)viewDidLoad [foursquareExampleButton addTarget:self action:@selector(foursquareExampleButtonPressed) forControlEvents:UIControlEventTouchUpInside]; [foursquareExampleButton setTitle:@"Foursquare" forState:UIControlStateNormal]; [self.view addSubview:foursquareExampleButton]; + + UIButton *presentedVCExampleButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; + presentedVCExampleButton.frame = CGRectMake((self.view.frame.size.width - 200) / 2.0f, 170, 200, 40); + presentedVCExampleButton.autoresizingMask = UIViewAutoresizingFlexibleWidth; + [presentedVCExampleButton addTarget:self action:@selector(presentVCButtonPressed) forControlEvents:UIControlEventTouchUpInside]; + [presentedVCExampleButton setTitle:@"Presented ViewController" forState:UIControlStateNormal]; + [self.view addSubview:presentedVCExampleButton]; } #pragma mark - @@ -108,6 +116,11 @@ - (void)foursquareExampleButtonPressed [composeViewController presentFromRootViewController]; } +- (void)presentVCButtonPressed +{ + [self presentViewController:[ModalViewController new] animated:YES completion:nil]; +} + #pragma mark - #pragma mark Orientation