diff --git a/PartTwo/PartTwo.xcodeproj/project.pbxproj b/PartTwo/PartTwo.xcodeproj/project.pbxproj index 5582517..e05ff47 100644 --- a/PartTwo/PartTwo.xcodeproj/project.pbxproj +++ b/PartTwo/PartTwo.xcodeproj/project.pbxproj @@ -9,12 +9,14 @@ /* Begin PBXBuildFile section */ 8DD103491BA66E0900CE483B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DD103481BA66E0900CE483B /* main.m */; }; 8DD1034C1BA66E0900CE483B /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DD1034B1BA66E0900CE483B /* AppDelegate.m */; }; - 8DD1034F1BA66E0900CE483B /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DD1034E1BA66E0900CE483B /* ViewController.m */; }; 8DD103521BA66E0900CE483B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8DD103501BA66E0900CE483B /* Main.storyboard */; }; 8DD103541BA66E0900CE483B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8DD103531BA66E0900CE483B /* Assets.xcassets */; }; 8DD103571BA66E0900CE483B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8DD103551BA66E0900CE483B /* LaunchScreen.storyboard */; }; 8DD103621BA66E0900CE483B /* PartTwoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DD103611BA66E0900CE483B /* PartTwoTests.m */; }; 8DD1036D1BA66E0900CE483B /* PartTwoUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DD1036C1BA66E0900CE483B /* PartTwoUITests.m */; }; + AB5C55A31BAD00D300326F61 /* BackgroundViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AB5C55A21BAD00D300326F61 /* BackgroundViewController.m */; }; + AB5C55A71BAD017D00326F61 /* CustomView.m in Sources */ = {isa = PBXBuildFile; fileRef = AB5C55A61BAD017D00326F61 /* CustomView.m */; }; + AB5C55A91BAD01CC00326F61 /* CustomView.xib in Resources */ = {isa = PBXBuildFile; fileRef = AB5C55A81BAD01CC00326F61 /* CustomView.xib */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -39,8 +41,6 @@ 8DD103481BA66E0900CE483B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 8DD1034A1BA66E0900CE483B /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 8DD1034B1BA66E0900CE483B /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - 8DD1034D1BA66E0900CE483B /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; - 8DD1034E1BA66E0900CE483B /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 8DD103511BA66E0900CE483B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 8DD103531BA66E0900CE483B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 8DD103561BA66E0900CE483B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; @@ -51,6 +51,12 @@ 8DD103681BA66E0900CE483B /* PartTwoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PartTwoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 8DD1036C1BA66E0900CE483B /* PartTwoUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PartTwoUITests.m; sourceTree = ""; }; 8DD1036E1BA66E0900CE483B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + AB5C55A11BAD00D300326F61 /* BackgroundViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BackgroundViewController.h; sourceTree = ""; }; + AB5C55A21BAD00D300326F61 /* BackgroundViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BackgroundViewController.m; sourceTree = ""; }; + AB5C55A41BAD00F800326F61 /* CustomViewDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomViewDelegate.h; sourceTree = ""; }; + AB5C55A51BAD017D00326F61 /* CustomView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomView.h; sourceTree = ""; }; + AB5C55A61BAD017D00326F61 /* CustomView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CustomView.m; sourceTree = ""; }; + AB5C55A81BAD01CC00326F61 /* CustomView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CustomView.xib; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -103,8 +109,12 @@ children = ( 8DD1034A1BA66E0900CE483B /* AppDelegate.h */, 8DD1034B1BA66E0900CE483B /* AppDelegate.m */, - 8DD1034D1BA66E0900CE483B /* ViewController.h */, - 8DD1034E1BA66E0900CE483B /* ViewController.m */, + AB5C55A11BAD00D300326F61 /* BackgroundViewController.h */, + AB5C55A21BAD00D300326F61 /* BackgroundViewController.m */, + AB5C55A41BAD00F800326F61 /* CustomViewDelegate.h */, + AB5C55A51BAD017D00326F61 /* CustomView.h */, + AB5C55A61BAD017D00326F61 /* CustomView.m */, + AB5C55A81BAD01CC00326F61 /* CustomView.xib */, 8DD103501BA66E0900CE483B /* Main.storyboard */, 8DD103531BA66E0900CE483B /* Assets.xcassets */, 8DD103551BA66E0900CE483B /* LaunchScreen.storyboard */, @@ -244,6 +254,7 @@ buildActionMask = 2147483647; files = ( 8DD103571BA66E0900CE483B /* LaunchScreen.storyboard in Resources */, + AB5C55A91BAD01CC00326F61 /* CustomView.xib in Resources */, 8DD103541BA66E0900CE483B /* Assets.xcassets in Resources */, 8DD103521BA66E0900CE483B /* Main.storyboard in Resources */, ); @@ -270,8 +281,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 8DD1034F1BA66E0900CE483B /* ViewController.m in Sources */, 8DD1034C1BA66E0900CE483B /* AppDelegate.m in Sources */, + AB5C55A71BAD017D00326F61 /* CustomView.m in Sources */, + AB5C55A31BAD00D300326F61 /* BackgroundViewController.m in Sources */, 8DD103491BA66E0900CE483B /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -412,7 +424,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = PartTwo/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.2; + IPHONEOS_DEPLOYMENT_TARGET = 8.4; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mikekavouras.PartTwo; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -424,7 +436,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = PartTwo/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.2; + IPHONEOS_DEPLOYMENT_TARGET = 8.4; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mikekavouras.PartTwo; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -436,6 +448,7 @@ buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; INFOPLIST_FILE = PartTwoTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.4; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mikekavouras.PartTwoTests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -448,6 +461,7 @@ buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; INFOPLIST_FILE = PartTwoTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.4; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mikekavouras.PartTwoTests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -459,6 +473,7 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = PartTwoUITests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.4; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mikekavouras.PartTwoUITests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -471,6 +486,7 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = PartTwoUITests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.4; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mikekavouras.PartTwoUITests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -498,6 +514,7 @@ 8DD103731BA66E0900CE483B /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 8DD103741BA66E0900CE483B /* Build configuration list for PBXNativeTarget "PartTwoTests" */ = { isa = XCConfigurationList; @@ -506,6 +523,7 @@ 8DD103761BA66E0900CE483B /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 8DD103771BA66E0900CE483B /* Build configuration list for PBXNativeTarget "PartTwoUITests" */ = { isa = XCConfigurationList; @@ -514,6 +532,7 @@ 8DD103791BA66E0900CE483B /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/PartTwo/PartTwo/BackgroundViewController.h b/PartTwo/PartTwo/BackgroundViewController.h new file mode 100644 index 0000000..279243e --- /dev/null +++ b/PartTwo/PartTwo/BackgroundViewController.h @@ -0,0 +1,13 @@ +// +// BackgroundViewController.h +// PartTwo +// +// Created by Bereket on 9/18/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import + +@interface BackgroundViewController : UIViewController + +@end diff --git a/PartTwo/PartTwo/BackgroundViewController.m b/PartTwo/PartTwo/BackgroundViewController.m new file mode 100644 index 0000000..126b02c --- /dev/null +++ b/PartTwo/PartTwo/BackgroundViewController.m @@ -0,0 +1,64 @@ +// +// BackgroundViewController.m +// PartTwo +// +// Created by Bereket on 9/18/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "BackgroundViewController.h" +#import "CustomView.h" +#import "CustomViewDelegate.h" + +@interface BackgroundViewController () + +@property (strong, nonatomic) IBOutlet UIView *customViewContainer; + +@property (nonatomic) CustomView *customView; +@end + +@implementation BackgroundViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view. + + NSArray *views = [[NSBundle mainBundle] loadNibNamed:@"CustomView" owner:self options:nil]; + self.customView = [views firstObject]; + + [self.customViewContainer addSubview:self.customView]; + self.customView.frame = self.customViewContainer.bounds; + + self.customView.delegate = self; + + +} + + +- (void)socialMediaViewDidTapLikeButton:(CustomView *)view { + self.view.backgroundColor = [UIColor blueColor]; +} +- (void)socialMediaViewDidTapCommentButton:(CustomView *)view { + self.view.backgroundColor = [UIColor greenColor]; +} +- (void)socialMediaViewDidTapShareButton:(CustomView *)view{ + self.view.backgroundColor = [UIColor redColor]; +} + + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +@end diff --git a/PartTwo/PartTwo/Base.lproj/Main.storyboard b/PartTwo/PartTwo/Base.lproj/Main.storyboard index f56d2f3..8abb2df 100644 --- a/PartTwo/PartTwo/Base.lproj/Main.storyboard +++ b/PartTwo/PartTwo/Base.lproj/Main.storyboard @@ -1,13 +1,13 @@ - + - + - + - + @@ -15,8 +15,23 @@ + + + + + + + + + + + + + + + diff --git a/PartTwo/PartTwo/CustomView.h b/PartTwo/PartTwo/CustomView.h new file mode 100644 index 0000000..90be486 --- /dev/null +++ b/PartTwo/PartTwo/CustomView.h @@ -0,0 +1,16 @@ +// +// CustomView.h +// PartTwo +// +// Created by Bereket on 9/18/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import +#import "CustomViewDelegate.h" + +@interface CustomView : UIView + +@property (nonatomic, weak) id delegate; + +@end diff --git a/PartTwo/PartTwo/CustomView.m b/PartTwo/PartTwo/CustomView.m new file mode 100644 index 0000000..0396517 --- /dev/null +++ b/PartTwo/PartTwo/CustomView.m @@ -0,0 +1,26 @@ +// +// CustomView.m +// PartTwo +// +// Created by Bereket on 9/18/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "CustomView.h" + +@implementation CustomView + +- (IBAction)likeButton:(id)sender { + [self.delegate socialMediaViewDidTapLikeButton:self]; +} + +- (IBAction)commentButton:(id)sender { + [self.delegate socialMediaViewDidTapCommentButton:self]; +} + +- (IBAction)shareButton:(id)sender { + [self.delegate socialMediaViewDidTapShareButton:self]; +} + + +@end diff --git a/PartTwo/PartTwo/CustomView.xib b/PartTwo/PartTwo/CustomView.xib new file mode 100644 index 0000000..c20546f --- /dev/null +++ b/PartTwo/PartTwo/CustomView.xib @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PartTwo/PartTwo/CustomViewDelegate.h b/PartTwo/PartTwo/CustomViewDelegate.h new file mode 100644 index 0000000..6476b62 --- /dev/null +++ b/PartTwo/PartTwo/CustomViewDelegate.h @@ -0,0 +1,19 @@ +// +// CustomViewDelegate.h +// PartTwo +// +// Created by Bereket on 9/18/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import + +@class CustomView; + +@protocol CustomViewDelegate + +- (void)socialMediaViewDidTapLikeButton:(CustomView *)view; +- (void)socialMediaViewDidTapCommentButton:(CustomView *)view; +- (void)socialMediaViewDidTapShareButton:(CustomView *)view; + +@end diff --git a/PartTwo/PartTwo/ViewController.h b/PartTwo/PartTwo/ViewController.h deleted file mode 100644 index cb5d98b..0000000 --- a/PartTwo/PartTwo/ViewController.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// ViewController.h -// PartTwo -// -// Created by Michael Kavouras on 9/13/15. -// Copyright © 2015 Mike Kavouras. All rights reserved. -// - -#import - -@interface ViewController : UIViewController - - -@end - diff --git a/PartTwo/PartTwo/ViewController.m b/PartTwo/PartTwo/ViewController.m deleted file mode 100644 index adca251..0000000 --- a/PartTwo/PartTwo/ViewController.m +++ /dev/null @@ -1,27 +0,0 @@ -// -// ViewController.m -// PartTwo -// -// Created by Michael Kavouras on 9/13/15. -// Copyright © 2015 Mike Kavouras. All rights reserved. -// - -#import "ViewController.h" - -@interface ViewController () - -@end - -@implementation ViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - // Do any additional setup after loading the view, typically from a nib. -} - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -@end diff --git a/PickAPic/PickAPic.xcodeproj/project.pbxproj b/PickAPic/PickAPic.xcodeproj/project.pbxproj index 049896b..ed9edbf 100644 --- a/PickAPic/PickAPic.xcodeproj/project.pbxproj +++ b/PickAPic/PickAPic.xcodeproj/project.pbxproj @@ -436,6 +436,7 @@ buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; INFOPLIST_FILE = PickAPicTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 7.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mikekavouras.PickAPicTests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -448,6 +449,7 @@ buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; INFOPLIST_FILE = PickAPicTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 7.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mikekavouras.PickAPicTests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -459,6 +461,7 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = PickAPicUITests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 7.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mikekavouras.PickAPicUITests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -471,6 +474,7 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = PickAPicUITests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 7.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mikekavouras.PickAPicUITests; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/PickAPic/PickAPic/Base.lproj/Main.storyboard b/PickAPic/PickAPic/Base.lproj/Main.storyboard index f055f71..77822aa 100644 --- a/PickAPic/PickAPic/Base.lproj/Main.storyboard +++ b/PickAPic/PickAPic/Base.lproj/Main.storyboard @@ -1,8 +1,7 @@ - + - - + @@ -16,8 +15,34 @@ + + + + + + + + + + + + + + + + + + diff --git a/PickAPic/PickAPic/ViewController.h b/PickAPic/PickAPic/ViewController.h index dee0930..37f3eb9 100644 --- a/PickAPic/PickAPic/ViewController.h +++ b/PickAPic/PickAPic/ViewController.h @@ -10,6 +10,11 @@ @interface ViewController : UIViewController +; + + + + @end diff --git a/PickAPic/PickAPic/ViewController.m b/PickAPic/PickAPic/ViewController.m index acd6613..1380d20 100644 --- a/PickAPic/PickAPic/ViewController.m +++ b/PickAPic/PickAPic/ViewController.m @@ -10,9 +10,55 @@ @interface ViewController () +@property (strong, nonatomic) IBOutlet UIImageView *myImage; + +@property (strong, nonatomic) UIImagePickerController* imagePicker; + + +@property (weak, nonatomic) IBOutlet UIButton *cameraRollButton; + + @end @implementation ViewController +@synthesize myImage, imagePicker; + + +-(void)viewDidLoad{ + [super viewDidLoad]; + self.imagePicker = [[UIImagePickerController alloc] init]; + self.imagePicker.delegate = self; +} + +-(IBAction)pickImageTapped:(id)sender{ + + + if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){ + + imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; + } + else{ + imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; + } + + [self presentViewController:imagePicker animated:YES completion:nil]; + +} + + +-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ + + + self.myImage.image = [info objectForKey:UIImagePickerControllerOriginalImage]; + [self dismissViewControllerAnimated:YES completion:nil]; + +} + +-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ + + myImage.image = [info objectForKey:UIImagePickerControllerOriginalImage]; + [self dismissViewControllerAnimated:YES completion:nil]; +} @end