Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions PartTwo/PartTwo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
0BFBF05C1BAD0612009898AA /* AVSocialMediaView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0BFBF05B1BAD0612009898AA /* AVSocialMediaView.m */; settings = {ASSET_TAGS = (); }; };
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 */; };
Expand Down Expand Up @@ -35,6 +36,9 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
0BFBF05A1BAD0612009898AA /* AVSocialMediaView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AVSocialMediaView.h; sourceTree = "<group>"; };
0BFBF05B1BAD0612009898AA /* AVSocialMediaView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AVSocialMediaView.m; sourceTree = "<group>"; };
0BFBF05D1BAD0640009898AA /* AVColorPickerCommProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AVColorPickerCommProtocol.h; sourceTree = "<group>"; };
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 = "<group>"; };
8DD1034A1BA66E0900CE483B /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -105,6 +109,9 @@
8DD1034B1BA66E0900CE483B /* AppDelegate.m */,
8DD1034D1BA66E0900CE483B /* ViewController.h */,
8DD1034E1BA66E0900CE483B /* ViewController.m */,
0BFBF05A1BAD0612009898AA /* AVSocialMediaView.h */,
0BFBF05B1BAD0612009898AA /* AVSocialMediaView.m */,
0BFBF05D1BAD0640009898AA /* AVColorPickerCommProtocol.h */,
8DD103501BA66E0900CE483B /* Main.storyboard */,
8DD103531BA66E0900CE483B /* Assets.xcassets */,
8DD103551BA66E0900CE483B /* LaunchScreen.storyboard */,
Expand Down Expand Up @@ -273,6 +280,7 @@
8DD1034F1BA66E0900CE483B /* ViewController.m in Sources */,
8DD1034C1BA66E0900CE483B /* AppDelegate.m in Sources */,
8DD103491BA66E0900CE483B /* main.m in Sources */,
0BFBF05C1BAD0612009898AA /* AVSocialMediaView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -498,6 +506,7 @@
8DD103731BA66E0900CE483B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
8DD103741BA66E0900CE483B /* Build configuration list for PBXNativeTarget "PartTwoTests" */ = {
isa = XCConfigurationList;
Expand All @@ -506,6 +515,7 @@
8DD103761BA66E0900CE483B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
8DD103771BA66E0900CE483B /* Build configuration list for PBXNativeTarget "PartTwoUITests" */ = {
isa = XCConfigurationList;
Expand All @@ -514,6 +524,7 @@
8DD103791BA66E0900CE483B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
15 changes: 15 additions & 0 deletions PartTwo/PartTwo/AVColorPickerCommProtocol.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// AVColorPickerCommProtocol.h
// PartTwo
//
// Created by Artur Lan on 9/18/15.
// Copyright © 2015 Mike Kavouras. All rights reserved.
//

#import <Foundation/Foundation.h>

@protocol AVColorPickerCommProtocol <NSObject>

-(void)didSelectColor:(UIColor *)color;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider making this more general. didTapCommentButton instead of didSelectColor. didSelectColor implies intent, and the protocol should be oblivious to intent.


@end
18 changes: 18 additions & 0 deletions PartTwo/PartTwo/AVSocialMediaView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// AVSocialMediaView.h
// PartTwo
//
// Created by Artur Lan on 9/18/15.
// Copyright © 2015 Mike Kavouras. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "AVColorPickerCommProtocol.h"
#import "AVSocialMediaView.h"

@interface AVSocialMediaView : UIView

@property (nonatomic, weak) id <AVColorPickerCommProtocol> delegate;


@end
28 changes: 28 additions & 0 deletions PartTwo/PartTwo/AVSocialMediaView.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// AVSocialMediaView.m
// PartTwo
//
// Created by Artur Lan on 9/18/15.
// Copyright © 2015 Mike Kavouras. All rights reserved.
//

#import "AVSocialMediaView.h"
#import "AVColorPickerCommProtocol.h"


@implementation AVSocialMediaView

- (IBAction)commentButtonTapped:(id)sender {
UIColor *color = [UIColor redColor];
[self.delegate didSelectColor:color];
}
- (IBAction)likeButtonTapped:(id)sender {
UIColor *color = [UIColor greenColor];
[self.delegate didSelectColor:color];
}
- (IBAction)shareButtonTapped:(id)sender {
UIColor *color = [UIColor blueColor];
[self.delegate didSelectColor:color];
}

@end
54 changes: 51 additions & 3 deletions PartTwo/PartTwo/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,25 +1,73 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
<viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="xcy-PO-TvN" userLabel="customView" customClass="AVSocialMediaView">
<rect key="frame" x="170" y="120" width="260" height="350"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="pN4-rP-PRo">
<rect key="frame" x="107" y="160" width="46" height="30"/>
<state key="normal" title="Like"/>
<connections>
<action selector="likeButtonTapped:" destination="xcy-PO-TvN" eventType="touchUpInside" id="jgz-cu-Xex"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hv4-PP-Jf1">
<rect key="frame" x="110" y="240" width="40" height="30"/>
<state key="normal" title="Share"/>
<connections>
<action selector="shareButtonTapped:" destination="xcy-PO-TvN" eventType="touchUpInside" id="dWX-02-ato"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Ecp-9P-vue">
<rect key="frame" x="96" y="80" width="67" height="30"/>
<state key="normal" title="Comment"/>
<connections>
<action selector="commentButtonTapped:" destination="xcy-PO-TvN" eventType="touchUpInside" id="uRi-bv-n2v"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="Ecp-9P-vue" firstAttribute="centerX" secondItem="xcy-PO-TvN" secondAttribute="centerX" id="BhL-Ec-iIS"/>
<constraint firstItem="hv4-PP-Jf1" firstAttribute="centerX" secondItem="xcy-PO-TvN" secondAttribute="centerX" id="Iqz-R9-86C"/>
<constraint firstAttribute="width" constant="260" id="QSW-Un-Ib0"/>
<constraint firstAttribute="height" constant="350" id="a4d-oV-38n"/>
<constraint firstItem="pN4-rP-PRo" firstAttribute="top" secondItem="Ecp-9P-vue" secondAttribute="bottom" constant="50" id="bJ2-9a-uGU"/>
<constraint firstItem="pN4-rP-PRo" firstAttribute="centerX" secondItem="xcy-PO-TvN" secondAttribute="centerX" id="gJy-A5-yAd"/>
<constraint firstItem="hv4-PP-Jf1" firstAttribute="top" secondItem="pN4-rP-PRo" secondAttribute="bottom" constant="50" id="wBe-44-PYd"/>
<constraint firstItem="pN4-rP-PRo" firstAttribute="centerY" secondItem="xcy-PO-TvN" secondAttribute="centerY" id="yxa-HP-scf"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="xcy-PO-TvN" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="IC1-lg-mal"/>
<constraint firstItem="xcy-PO-TvN" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" constant="100" id="IbW-ur-RPO"/>
</constraints>
</view>
<connections>
<outlet property="customView" destination="xcy-PO-TvN" id="VbY-Zs-9Sw"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="140" y="362"/>
</scene>
</scenes>
</document>
1 change: 1 addition & 0 deletions PartTwo/PartTwo/ViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

@interface ViewController : UIViewController

@property (nonatomic) UIImage *imageView;

@end

16 changes: 10 additions & 6 deletions PartTwo/PartTwo/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,25 @@
//

#import "ViewController.h"
#import "AVColorPickerCommProtocol.h"
#import "AVSocialMediaView.h"

@interface ViewController () <AVColorPickerCommProtocol>

@property (weak, nonatomic) IBOutlet AVSocialMediaView *customView;

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.customView.delegate = self;

}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
-(void)didSelectColor:(UIColor *)color {
self.view.backgroundColor = color;
}

@end
17 changes: 16 additions & 1 deletion PickAPic/PickAPic/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="14E46" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<scenes>
<!--View Controller-->
Expand All @@ -16,8 +17,22 @@
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="9of-NG-seS">
<rect key="frame" x="20" y="20" width="560" height="580"/>
</imageView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="9of-NG-seS" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" id="YeD-5S-i0e"/>
<constraint firstItem="wfy-db-euE" firstAttribute="top" secondItem="9of-NG-seS" secondAttribute="bottom" id="ZhS-13-knd"/>
<constraint firstItem="9of-NG-seS" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" id="aYf-P0-hZm"/>
<constraint firstAttribute="trailingMargin" secondItem="9of-NG-seS" secondAttribute="trailing" id="uKQ-AJ-xzN"/>
</constraints>
</view>
<connections>
<outlet property="imageView" destination="9of-NG-seS" id="kb0-Vv-wA6"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
Expand Down
5 changes: 4 additions & 1 deletion PickAPic/PickAPic/ViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
@interface ViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate>

@property (strong, nonatomic) IBOutlet UIImageView *imageView;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should try to keep all @property in the .m unless another object needs to access that property. In this case, the only object accessing imageView is ViewController, so you should move this to the @interface in the .m.




@end
Expand Down
32 changes: 32 additions & 0 deletions PickAPic/PickAPic/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,37 @@ @interface ViewController ()

@implementation ViewController

-(void)viewDidLoad {
[super viewDidLoad];
}

-(void)viewDidAppear:(BOOL)animated {
if (self.imageView.image == nil) {
[super viewDidAppear:animated];
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc]init];
imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
imagePickerController.delegate = self;
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:imagePickerController animated:NO completion:nil];
}
else {

}
}

-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[self dismissViewControllerAnimated:YES completion:nil];
}

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info {
UIImage *image = [info valueForKey:UIImagePickerControllerOriginalImage];
self.imageView.image = image;
[self dismissViewControllerAnimated:YES completion:nil];
}

-(void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}


@end