Skip to content

Commit

Permalink
fix demo codes
Browse files Browse the repository at this point in the history
  • Loading branch information
metasmile committed May 3, 2017
1 parent 9fbd692 commit 3bca7dc
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 22 deletions.
10 changes: 10 additions & 0 deletions DemoProject/NSGIF/Images.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
Expand Down
6 changes: 6 additions & 0 deletions DemoProject/NSGIF/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,11 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>NSCameraUsageDescription</key>
<string>This app uses your camera to take amazing photos. It works best when you allow. Thanks!
</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app uses your camera to take amazing photos. It works best when you allow. Thanks!
</string>
</dict>
</plist>
42 changes: 21 additions & 21 deletions DemoProject/NSGIF/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,22 @@ - (IBAction)button1Tapped:(id)sender {
- (IBAction)button2Tapped:(id)sender {

#if TARGET_IPHONE_SIMULATOR
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Oops!" message:@"You can't use the camera demo in the simulator. Try the video demo." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
return;

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Oops!" message:@"You can't use the camera demo in the simulator. Try the video demo." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];

#else

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.videoQuality = UIImagePickerControllerQualityTypeMedium;
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = @[(NSString *)kUTTypeMovie];

// Present the picker
[self presentViewController:picker animated:YES completion:nil];

#endif

dispatch_async(dispatch_get_main_queue(), ^{

UIImagePickerController *picker = [[UIImagePickerController alloc]init];
picker.videoQuality = UIImagePickerControllerQualityTypeMedium;
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = @[(NSString *)kUTTypeMovie];

// Present the picker
[self presentViewController:picker animated:YES completion:nil];
});
}

- (IBAction)button3Tapped:(id)sender {
Expand All @@ -134,26 +134,26 @@ - (IBAction)button3Tapped:(id)sender {
request.aspectRatioToCrop = CGSizeMake(4,3);
request.frameCount = 10;

[NSGIF extract:request completion:^(NSArray<NSURL *> *extractedFrameImageUrls) {
NSLog(@"Finished generating frames: %@", extractedFrameImageUrls);

[NSGIF extract:request completion:^(NSFrameExtractingResponse * response) {

[self.activityIndicator stopAnimating];
[UIView animateWithDuration:0.3 animations:^{
self.button1.alpha = 0.0f;
self.button2.alpha = 0.0f;
self.button3.alpha = 0.0f;
self.webView.alpha = 1.0f;
}];

for(NSURL * imageUrl in extractedFrameImageUrls){
for(NSURL * imageUrl in response.imageUrls){
UIImage * image = [UIImage imageWithContentsOfFile:imageUrl.path];
UIView * imageView = [[UIImageView alloc] initWithImage:image];
imageView.contentMode = UIViewContentModeScaleAspectFit;
imageView.frame = CGRectMake(0,((CGFloat)[extractedFrameImageUrls indexOfObject:imageUrl])*(image.size.height/6), image.size.width/6,image.size.height/6);
imageView.frame = CGRectMake(0,((CGFloat)[response.imageUrls indexOfObject:imageUrl])*(image.size.height/6), image.size.width/6,image.size.height/6);
imageView.clipsToBounds = YES;
imageView.layer.borderWidth = 1;
[scrollView addSubview:imageView];
}

}];

[self.view addSubview:scrollView];
Expand Down
2 changes: 1 addition & 1 deletion NSGIF/NSGIF.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ typedef void (^ NSGIFProgressHandler)(double progress, NSUInteger offset, NSUInt
#pragma mark NSSerializedResourceResponse
@interface NSSerializedResourceResponse : NSObject

@property(nonatomic, readonly) NSArray<NSURL *> * imageUrls;
@property(nullable, nonatomic, readonly) NSArray<NSURL *> * imageUrls;

@end

Expand Down

0 comments on commit 3bca7dc

Please sign in to comment.