-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
500 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// CameraViewController.h | ||
// unnamed | ||
// | ||
// Created by Bruce Ng on 2/23/15. | ||
// Copyright (c) 2015 com.yahoo. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@class CameraViewController; | ||
@protocol CameraViewControllerDelegate <NSObject> | ||
|
||
- (void)cameraViewController:(CameraViewController *)vc didSelectPhoto:(UIImage *)photo; | ||
|
||
@end | ||
|
||
@interface CameraViewController : UIViewController | ||
@property (nonatomic, assign) NSIndexPath *indexPath; | ||
@property (nonatomic,strong) id<CameraViewControllerDelegate> delegate; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// | ||
// CameraViewController.m | ||
// unnamed | ||
// | ||
// Created by Bruce Ng on 2/23/15. | ||
// Copyright (c) 2015 com.yahoo. All rights reserved. | ||
// | ||
|
||
#import "CameraViewController.h" | ||
|
||
@interface CameraViewController () <UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIAlertViewDelegate> | ||
@property (weak, nonatomic) IBOutlet UIButton *takePhotoButton; | ||
@property (weak, nonatomic) IBOutlet UIButton *selectPhotoButton; | ||
@property (strong, nonatomic) IBOutlet UIImageView *photoImageView; | ||
|
||
@end | ||
|
||
@implementation CameraViewController | ||
|
||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
// Do any additional setup after loading the view from its nib. | ||
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { | ||
|
||
UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Error" | ||
message:@"Device has no camera" | ||
delegate:self | ||
cancelButtonTitle:@"OK" | ||
otherButtonTitles: nil]; | ||
|
||
[myAlertView show]; | ||
|
||
} | ||
} | ||
|
||
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { | ||
self.takePhotoButton.enabled = NO; | ||
} | ||
|
||
- (void)didReceiveMemoryWarning { | ||
[super didReceiveMemoryWarning]; | ||
// Dispose of any resources that can be recreated. | ||
} | ||
- (IBAction)onTakePhoto:(UIButton *)sender { | ||
UIImagePickerController *picker = [[UIImagePickerController alloc] init]; | ||
picker.delegate = self; | ||
picker.allowsEditing = YES; | ||
picker.sourceType = UIImagePickerControllerSourceTypeCamera; | ||
|
||
[self presentViewController:picker animated:YES completion:NULL]; | ||
} | ||
|
||
- (IBAction)onSelectPhoto:(UIButton *)sender { | ||
UIImagePickerController *picker = [[UIImagePickerController alloc] init]; | ||
picker.delegate = self; | ||
picker.allowsEditing = YES; | ||
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; | ||
|
||
[self presentViewController:picker animated:YES completion:NULL]; | ||
} | ||
|
||
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { | ||
|
||
UIImage *chosenImage = info[UIImagePickerControllerEditedImage]; | ||
self.photoImageView.image = chosenImage; | ||
|
||
[picker dismissViewControllerAnimated:YES completion:NULL]; | ||
|
||
[self.delegate cameraViewController:self didSelectPhoto:chosenImage]; | ||
|
||
|
||
} | ||
|
||
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { | ||
|
||
[picker dismissViewControllerAnimated:YES completion:NULL]; | ||
|
||
} | ||
|
||
/* | ||
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6254" systemVersion="13F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES"> | ||
<dependencies> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/> | ||
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/> | ||
</dependencies> | ||
<objects> | ||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="CameraViewController"> | ||
<connections> | ||
<outlet property="photoImageView" destination="vXb-iN-7Vp" id="wRU-ku-g3j"/> | ||
<outlet property="selectPhotoButton" destination="J2U-4C-9gb" id="A35-IU-PX1"/> | ||
<outlet property="takePhotoButton" destination="3qn-rV-o56" id="3XI-hf-ws1"/> | ||
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> | ||
</connections> | ||
</placeholder> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> | ||
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT"> | ||
<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="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="vXb-iN-7Vp"> | ||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/> | ||
<constraints> | ||
<constraint firstAttribute="width" secondItem="vXb-iN-7Vp" secondAttribute="height" multiplier="1:1" id="erW-fD-vS7"/> | ||
</constraints> | ||
</imageView> | ||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3qn-rV-o56"> | ||
<rect key="frame" x="262" y="530" width="77" height="30"/> | ||
<state key="normal" title="Take Photo"> | ||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/> | ||
</state> | ||
<connections> | ||
<action selector="onTakePhoto:" destination="-1" eventType="touchUpInside" id="KQg-oJ-n6v"/> | ||
</connections> | ||
</button> | ||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="J2U-4C-9gb"> | ||
<rect key="frame" x="504" y="531" width="88" height="30"/> | ||
<state key="normal" title="Select Photo"> | ||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/> | ||
</state> | ||
<connections> | ||
<action selector="onSelectPhoto:" destination="-1" eventType="touchUpInside" id="O9J-xs-i6Q"/> | ||
</connections> | ||
</button> | ||
</subviews> | ||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> | ||
<constraints> | ||
<constraint firstAttribute="bottom" secondItem="J2U-4C-9gb" secondAttribute="bottom" constant="39" id="08R-fW-wtk"/> | ||
<constraint firstItem="vXb-iN-7Vp" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" id="2w7-FZ-TFL"/> | ||
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="vXb-iN-7Vp" secondAttribute="bottom" id="Akd-IX-D2n"/> | ||
<constraint firstAttribute="trailing" secondItem="J2U-4C-9gb" secondAttribute="trailing" constant="8" id="FaO-Go-8IS"/> | ||
<constraint firstItem="vXb-iN-7Vp" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="Frz-lF-6ZH"/> | ||
<constraint firstAttribute="centerX" secondItem="3qn-rV-o56" secondAttribute="centerX" id="Ktd-PS-Cux"/> | ||
<constraint firstAttribute="trailing" secondItem="vXb-iN-7Vp" secondAttribute="trailing" id="PQI-PG-V0d"/> | ||
<constraint firstAttribute="bottom" secondItem="3qn-rV-o56" secondAttribute="bottom" constant="40" id="a8N-RB-i56"/> | ||
</constraints> | ||
</view> | ||
</objects> | ||
</document> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// ComposePhotoCell.h | ||
// unnamed | ||
// | ||
// Created by Bruce Ng on 2/23/15. | ||
// Copyright (c) 2015 com.yahoo. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import "Answer.h" | ||
|
||
@interface ComposePhotoCell : UICollectionViewCell | ||
@property (nonatomic, strong) Answer *answer; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// ComposePhotoCell.m | ||
// unnamed | ||
// | ||
// Created by Bruce Ng on 2/23/15. | ||
// Copyright (c) 2015 com.yahoo. All rights reserved. | ||
// | ||
|
||
#import "ComposePhotoCell.h" | ||
#import "UIColor+AppColor.h" | ||
@interface ComposePhotoCell() | ||
@property (weak, nonatomic) IBOutlet UILabel *addPhotoLabel; | ||
@property (weak, nonatomic) IBOutlet UIImageView *photoView; | ||
@end | ||
|
||
@implementation ComposePhotoCell | ||
|
||
- (void)awakeFromNib { | ||
// Initialization code | ||
} | ||
|
||
- (void)layoutSubviews { | ||
if (self.answer && self.answer.photo) { | ||
[self.photoView setImage:self.answer.photo]; | ||
self.photoView.alpha = 1; | ||
self.addPhotoLabel.alpha = 0; | ||
} else { | ||
self.photoView.alpha = 0; | ||
self.addPhotoLabel.alpha = 1; | ||
} | ||
} | ||
|
||
@end |
Oops, something went wrong.