diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..a324cb6 Binary files /dev/null and b/.DS_Store differ diff --git a/PartTwo/.DS_Store b/PartTwo/.DS_Store new file mode 100644 index 0000000..fb07fcf Binary files /dev/null and b/PartTwo/.DS_Store differ diff --git a/PartTwo/PartTwo.xcodeproj/project.pbxproj b/PartTwo/PartTwo.xcodeproj/project.pbxproj index 5582517..33d2d25 100644 --- a/PartTwo/PartTwo.xcodeproj/project.pbxproj +++ b/PartTwo/PartTwo.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 4D0B9D241BA77BC70089A001 /* SocialMediaView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D0B9D231BA77BC70089A001 /* SocialMediaView.m */; }; 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 */; }; @@ -35,6 +36,9 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 4D0B9D211BA77BA60089A001 /* ButtonPressedProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ButtonPressedProtocol.h; sourceTree = ""; }; + 4D0B9D221BA77BC70089A001 /* SocialMediaView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocialMediaView.h; sourceTree = ""; }; + 4D0B9D231BA77BC70089A001 /* SocialMediaView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SocialMediaView.m; sourceTree = ""; }; 8DD103441BA66E0900CE483B /* PartTwo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PartTwo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 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 = ""; }; @@ -105,6 +109,9 @@ 8DD1034B1BA66E0900CE483B /* AppDelegate.m */, 8DD1034D1BA66E0900CE483B /* ViewController.h */, 8DD1034E1BA66E0900CE483B /* ViewController.m */, + 4D0B9D221BA77BC70089A001 /* SocialMediaView.h */, + 4D0B9D231BA77BC70089A001 /* SocialMediaView.m */, + 4D0B9D211BA77BA60089A001 /* ButtonPressedProtocol.h */, 8DD103501BA66E0900CE483B /* Main.storyboard */, 8DD103531BA66E0900CE483B /* Assets.xcassets */, 8DD103551BA66E0900CE483B /* LaunchScreen.storyboard */, @@ -272,6 +279,7 @@ files = ( 8DD1034F1BA66E0900CE483B /* ViewController.m in Sources */, 8DD1034C1BA66E0900CE483B /* AppDelegate.m in Sources */, + 4D0B9D241BA77BC70089A001 /* SocialMediaView.m in Sources */, 8DD103491BA66E0900CE483B /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -498,6 +506,7 @@ 8DD103731BA66E0900CE483B /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 8DD103741BA66E0900CE483B /* Build configuration list for PBXNativeTarget "PartTwoTests" */ = { isa = XCConfigurationList; @@ -506,6 +515,7 @@ 8DD103761BA66E0900CE483B /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 8DD103771BA66E0900CE483B /* Build configuration list for PBXNativeTarget "PartTwoUITests" */ = { isa = XCConfigurationList; @@ -514,6 +524,7 @@ 8DD103791BA66E0900CE483B /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/PartTwo/PartTwo.xcodeproj/project.xcworkspace/xcuserdata/shenayoshida.xcuserdatad/UserInterfaceState.xcuserstate b/PartTwo/PartTwo.xcodeproj/project.xcworkspace/xcuserdata/shenayoshida.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..ab2aefa Binary files /dev/null and b/PartTwo/PartTwo.xcodeproj/project.xcworkspace/xcuserdata/shenayoshida.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/PartTwo/PartTwo.xcodeproj/xcuserdata/shenayoshida.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/PartTwo/PartTwo.xcodeproj/xcuserdata/shenayoshida.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..fe2b454 --- /dev/null +++ b/PartTwo/PartTwo.xcodeproj/xcuserdata/shenayoshida.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,5 @@ + + + diff --git a/PartTwo/PartTwo.xcodeproj/xcuserdata/shenayoshida.xcuserdatad/xcschemes/PartTwo.xcscheme b/PartTwo/PartTwo.xcodeproj/xcuserdata/shenayoshida.xcuserdatad/xcschemes/PartTwo.xcscheme new file mode 100644 index 0000000..6e5b2b0 --- /dev/null +++ b/PartTwo/PartTwo.xcodeproj/xcuserdata/shenayoshida.xcuserdatad/xcschemes/PartTwo.xcscheme @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PartTwo/PartTwo.xcodeproj/xcuserdata/shenayoshida.xcuserdatad/xcschemes/xcschememanagement.plist b/PartTwo/PartTwo.xcodeproj/xcuserdata/shenayoshida.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..8d9c097 --- /dev/null +++ b/PartTwo/PartTwo.xcodeproj/xcuserdata/shenayoshida.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,32 @@ + + + + + SchemeUserState + + PartTwo.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 8DD103431BA66E0900CE483B + + primary + + + 8DD1035C1BA66E0900CE483B + + primary + + + 8DD103671BA66E0900CE483B + + primary + + + + + diff --git a/PartTwo/PartTwo/Base.lproj/Main.storyboard b/PartTwo/PartTwo/Base.lproj/Main.storyboard index f56d2f3..9cb60dc 100644 --- a/PartTwo/PartTwo/Base.lproj/Main.storyboard +++ b/PartTwo/PartTwo/Base.lproj/Main.storyboard @@ -1,13 +1,15 @@ - + - + + + - + @@ -15,11 +17,81 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PartTwo/PartTwo/ButtonPressedProtocol.h b/PartTwo/PartTwo/ButtonPressedProtocol.h new file mode 100644 index 0000000..e871ab4 --- /dev/null +++ b/PartTwo/PartTwo/ButtonPressedProtocol.h @@ -0,0 +1,21 @@ +// +// ButtonPressedProtocol.h +// PartTwo +// +// Created by Shena Yoshida on 9/14/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import + +@class SocialMediaView; + +@protocol ButtonPressedProtocol + +- (void)socialMediaViewDidTapLikeButton:(SocialMediaView *)view; + +- (void)socialMediaViewDidTapCommentButton:(SocialMediaView *)view; + +- (void)socialMediaViewDidTapShareButton:(SocialMediaView *)view; + +@end diff --git a/PartTwo/PartTwo/SocialMediaView.h b/PartTwo/PartTwo/SocialMediaView.h new file mode 100644 index 0000000..5e3c070 --- /dev/null +++ b/PartTwo/PartTwo/SocialMediaView.h @@ -0,0 +1,18 @@ +// +// SocialMediaView.h +// PartTwo +// +// Created by Shena Yoshida on 9/14/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import +#import "ButtonPressedProtocol.h" + +extern NSString * const MyCustomNotificationName; // public constant declaration for notification name + +@interface SocialMediaView : UIView + +@property (nonatomic, weak) id delegate; + +@end diff --git a/PartTwo/PartTwo/SocialMediaView.m b/PartTwo/PartTwo/SocialMediaView.m new file mode 100644 index 0000000..38a7c58 --- /dev/null +++ b/PartTwo/PartTwo/SocialMediaView.m @@ -0,0 +1,34 @@ +// +// SocialMediaView.m +// PartTwo +// +// Created by Shena Yoshida on 9/14/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import "SocialMediaView.h" + +NSString * const MyCustomNotificationName = @"MyCustomNotification"; // declare constant for notification and set string + +@interface SocialMediaView () + +@end + +@implementation SocialMediaView + +// required delegate methods: +- (IBAction)commentButtonTapped:(UIButton *)sender { + [self.delegate socialMediaViewDidTapCommentButton:self]; // connect delegate, when this button is tapped, pass message. +} + +- (IBAction)likeButtonTapped:(UIButton *)sender { + [self.delegate socialMediaViewDidTapLikeButton:self]; +} + +- (IBAction)shareButtonTapped:(UIButton *)sender { + // [self.delegate socialMediaViewDidTapShareButton:self]; + + [[NSNotificationCenter defaultCenter] postNotificationName:MyCustomNotificationName object:nil]; // broadcasting notification +} + +@end diff --git a/PartTwo/PartTwo/ViewController.m b/PartTwo/PartTwo/ViewController.m index adca251..7b4e745 100644 --- a/PartTwo/PartTwo/ViewController.m +++ b/PartTwo/PartTwo/ViewController.m @@ -7,8 +7,12 @@ // #import "ViewController.h" +#import "SocialMediaView.h" +#import "ButtonPressedProtocol.h" -@interface ViewController () +@interface ViewController () + +@property (strong, nonatomic) IBOutlet SocialMediaView *socialMediaView; // create property for delegate reference (this is the custom view) @end @@ -16,12 +20,25 @@ @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; - // Do any additional setup after loading the view, typically from a nib. + + self.socialMediaView.delegate = self; // assign delegate to the custom view property + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(socialMediaViewDidTapShareButton:) name:MyCustomNotificationName object:nil]; // add observer for didTapShareButton notification + +} + +// required delegate methods: +- (void)socialMediaViewDidTapCommentButton:(SocialMediaView *)view { + self.view.backgroundColor = [UIColor blueColor]; // change view background to blue +} + +- (void)socialMediaViewDidTapLikeButton:(SocialMediaView *)view { + self.view.backgroundColor = [UIColor redColor]; } -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. +- (void)socialMediaViewDidTapShareButton:(SocialMediaView *)view { + self.view.backgroundColor = [UIColor greenColor]; + } @end diff --git a/PickAPic/.DS_Store b/PickAPic/.DS_Store new file mode 100644 index 0000000..cdce7b3 Binary files /dev/null and b/PickAPic/.DS_Store differ diff --git a/PickAPic/PickAPic.xcodeproj/project.xcworkspace/xcuserdata/shenayoshida.xcuserdatad/UserInterfaceState.xcuserstate b/PickAPic/PickAPic.xcodeproj/project.xcworkspace/xcuserdata/shenayoshida.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..344f779 Binary files /dev/null and b/PickAPic/PickAPic.xcodeproj/project.xcworkspace/xcuserdata/shenayoshida.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/PickAPic/PickAPic.xcodeproj/xcuserdata/shenayoshida.xcuserdatad/xcschemes/PickAPic.xcscheme b/PickAPic/PickAPic.xcodeproj/xcuserdata/shenayoshida.xcuserdatad/xcschemes/PickAPic.xcscheme new file mode 100644 index 0000000..72d7729 --- /dev/null +++ b/PickAPic/PickAPic.xcodeproj/xcuserdata/shenayoshida.xcuserdatad/xcschemes/PickAPic.xcscheme @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PickAPic/PickAPic.xcodeproj/xcuserdata/shenayoshida.xcuserdatad/xcschemes/xcschememanagement.plist b/PickAPic/PickAPic.xcodeproj/xcuserdata/shenayoshida.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..bb91a10 --- /dev/null +++ b/PickAPic/PickAPic.xcodeproj/xcuserdata/shenayoshida.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,32 @@ + + + + + SchemeUserState + + PickAPic.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 8D1F73BB1BA66AE50040D369 + + primary + + + 8D1F73D41BA66AE50040D369 + + primary + + + 8D1F73DF1BA66AE50040D369 + + primary + + + + + diff --git a/PickAPic/PickAPic/Base.lproj/LaunchScreen.storyboard b/PickAPic/PickAPic/Base.lproj/LaunchScreen.storyboard index 2e721e1..aa08113 100644 --- a/PickAPic/PickAPic/Base.lproj/LaunchScreen.storyboard +++ b/PickAPic/PickAPic/Base.lproj/LaunchScreen.storyboard @@ -1,7 +1,8 @@ - + - + + diff --git a/PickAPic/PickAPic/Base.lproj/Main.storyboard b/PickAPic/PickAPic/Base.lproj/Main.storyboard index f055f71..62d7f02 100644 --- a/PickAPic/PickAPic/Base.lproj/Main.storyboard +++ b/PickAPic/PickAPic/Base.lproj/Main.storyboard @@ -1,8 +1,9 @@ - + + @@ -16,12 +17,36 @@ + + + + + + + + + + + + + + + + + + - + diff --git a/PickAPic/PickAPic/ViewController.h b/PickAPic/PickAPic/ViewController.h index dee0930..3256330 100644 --- a/PickAPic/PickAPic/ViewController.h +++ b/PickAPic/PickAPic/ViewController.h @@ -10,6 +10,7 @@ @interface ViewController : UIViewController +@property (strong, nonatomic) IBOutlet UIImageView *imageView; @end diff --git a/PickAPic/PickAPic/ViewController.m b/PickAPic/PickAPic/ViewController.m index acd6613..47ad399 100644 --- a/PickAPic/PickAPic/ViewController.m +++ b/PickAPic/PickAPic/ViewController.m @@ -8,11 +8,49 @@ #import "ViewController.h" -@interface ViewController () +@interface ViewController () + +@property (nonatomic, strong) UIImagePickerController *pickerController; +@property (strong, nonatomic) IBOutlet UIImageView *photoImageView; @end @implementation ViewController +- (IBAction)selectPhoto:(UIButton *)sender { // button tapped + + self.pickerController = [[UIImagePickerController alloc]init]; // create picker controller + self.pickerController.delegate = self; // we are the delgate of the picker controller + + [self presentViewController:self.pickerController animated:YES completion:nil]; // present the picker controller +} + +- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { // photo/video picked + + // test it + NSLog(@"did finish - image picker controller"); + + // convert to uiimage + UIImage *selectedImage = [info valueForKey:UIImagePickerControllerOriginalImage]; + + // grab info from selected image and create new image for the image view + self.photoImageView.image = selectedImage; + + NSLog(@"%@", info); // investigate - what is "info" + + // dismiss the image picker view + [self dismissViewControllerAnimated:YES completion:nil]; +} + +- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { // cancel button tapped + + NSLog(@"did cancel"); // test it + + // dismiss the image picker view + [self dismissViewControllerAnimated:YES completion:nil]; +} + + + @end