小编Aub*_*rey的帖子

如何在没有Storyboard的情况下在Swift中创建UICollectionView过渡动画?

我试图在Facebook的照片集合视图中显示这种效果:

视频:http://d.pr/v/YCDB

我的目标是:

  • 动画进出单元格的索引路径
  • 向上和向下平移以淡出视图并将其关闭
  • 几乎是视频中的内容.


我已经完成了淡出工作,但动画效果最差.

Zip到XCodeProject:

http://d.pr/f/19uw5


或者看看下面的代码

我的CollectionView:

import UIKit

class Feed: UIViewController, UICollectionViewDelegateFlowLayout, UICollectionViewDataSource {

var collectionView: UICollectionView?
var myArray = ["cool", "neat", "fun", "cool", "neat", "fun", "cool", "neat", "fun", "cool", "neat", "fun", "cool", "neat", "fun", "cool", "neat", "fun", "cool", "neat", "fun", "cool", "neat", "fun"]


override func viewDidLoad() {
    super.viewDidLoad()

    self.view.backgroundColor = UIColor.yellowColor()
    self.title = "Feed"

    let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
    layout.sectionInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
    layout.itemSize = …
Run Code Online (Sandbox Code Playgroud)

iphone uiviewanimationtransition ios uicollectionview swift

8
推荐指数
0
解决办法
3231
查看次数

如何使用 AVFoundation 将视频转换为动画 gif?

在使用 AVFoundation 和 AVCamRecorder 录制电影后,我正在推送一个新的 UIViewController。

目前我正在从保存电影的 URL 播放电影,并且工作正常。我在理解如何将视频从 URL 转换为动画 gif 时遇到了很多麻烦。

我是相当新的,以目标C和有成功创建一个漂亮的自定义视频录像机,但现在我不鼓励这个下一条。

我有

第二视图控制器.h

@interface SecondViewController : UIViewController
@property NSURL *videoURL;
@end
Run Code Online (Sandbox Code Playgroud)

第二视图控制器.m

#import "SecondViewController.h"
#import "FirstViewController.h"
#import "CaptureManager.h"
#import "AVCamRecorder.h"
#import <AVFoundation/AVFoundation.h>
#import <MediaPlayer/MediaPlayer.h>

@interface SecondViewController ()

@property (nonatomic, strong) CaptureManager *grabFile;
@property (nonatomic, strong) MPMoviePlayerController *movie;

@end

@implementation SecondViewController

- (void)viewDidLoad
{
self.movie = [[MPMoviePlayerController alloc] initWithContentURL:self.videoURL];
    _movie.view.frame = CGRectMake(0.0, 64.0, 320.0, 320.0);
    _movie.movieSourceType = MPMovieSourceTypeFile;
    _movie.repeatMode = MPMovieRepeatModeOne;
    [self.view addSubview:_movie.view];
    [_movie play];
} …
Run Code Online (Sandbox Code Playgroud)

objective-c animated-gif avfoundation

5
推荐指数
1
解决办法
2038
查看次数

在Swift中,您如何使用Velocity targetContentOffset方法编写scrollViewWillEndDragging?

怎么会在Swift中写这个?

更新:发布我正在尝试转换的方法,最初发布了一个不同于我试图隐藏的方法

这适用于Objective C,但不适用于Swift.我得到的转换错误,当我尝试使用ceilf,并floorfCGFloat.

    - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
{

    float pageWidth = 200 + 30; // width + space

    float currentOffset = scrollView.contentOffset.x;
    float targetOffset = targetContentOffset->x;
    float newTargetOffset = 0;

    if (targetOffset > currentOffset)
        newTargetOffset = ceilf(currentOffset / pageWidth) * pageWidth;
    else
        newTargetOffset = floorf(currentOffset / pageWidth) * pageWidth;

    if (newTargetOffset < 0)
        newTargetOffset = 0;
    else if (newTargetOffset > scrollView.contentSize.width)
        newTargetOffset = scrollView.contentSize.width;

    targetContentOffset->x = currentOffset; …
Run Code Online (Sandbox Code Playgroud)

xcode objective-c scrollview uicollectionview swift

5
推荐指数
2
解决办法
8894
查看次数

如何将图像保存到Parse的主要用户类?

我有以下方法:

- (void) savePhotoToUser {

    NSData *imageData = UIImageJPEGRepresentation(_imgView.image, 1.0);
    PFFile *imageFile = [PFFile fileWithName:@"img.png" data:imageData];

    [imageFile saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
        if (!error) {


            //THIS IS WHERE I NEED HELP
            //
            PFObject *userPhoto = [PFObject objectWithClassName:@"User"];
            //
            //

            [userPhoto setObject:imageFile forKey:@"profilePicture"];

            [userPhoto saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
                if (!error) {
                    NSLog(@"Saved %@ for user %@", imageFile, userPhoto);

                    //Push ViewController

                }
                else{
                    NSLog(@"Error: %@ %@", error, [error userInfo]);
                }
            }];
        }
        else{
            NSLog(@"Error: %@ %@", error, [error userInfo]);
        }
    }]; …
Run Code Online (Sandbox Code Playgroud)

xcode objective-c ios parse-platform

0
推荐指数
1
解决办法
4097
查看次数