小编Axe*_*l K的帖子

在iOS中作为背景的视频最有效的方法

也许您已经注意到iOS应用程序的最新趋势之一:使用视频作为背景 - 主要是在登录或"首次启动"屏幕.昨天我试图通过一个非常简单的测试项目(只有一个视图控制器)模仿这个,除了性能之外,我对结果很满意.在iOS模拟器中尝试(在模拟的iPhone 6上)时,CPU使用率70-110%之间波动.对于简单的登录屏幕来说,这似乎是非常不合理的.

这就是它的实际效果:http: //oi57.tinypic.com/nqqntv.jpg

问题是:是否有更有效的CPU方法来实现这一目标?Vine,Spotify和Instagram等应用程序如何做到这一点?

在你回答之前; 我使用的方法是使用MPMoviePlayerController播放的全高清视频:

- (void)viewDidLoad {
    [super viewDidLoad];

    // find movie file
    NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"arenaVideo" ofType:@"mp4"];
    NSURL *movieURL = [NSURL fileURLWithPath:moviePath];

    // load movie
    self.moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
    self.moviePlayer.controlStyle = MPMovieControlStyleNone;
    self.moviePlayer.view.frame = self.view.frame;
    self.moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
    [self.view addSubview:self.moviePlayer.view];
    [self.view sendSubviewToBack:self.moviePlayer.view];
    [self.moviePlayer play];

    // loop movie
    [[NSNotificationCenter defaultCenter] addObserver: self
                                             selector: @selector(replayMovie:)
                                                 name: MPMoviePlayerPlaybackDidFinishNotification
                                               object: self.moviePlayer];
}

#pragma mark - Helper …
Run Code Online (Sandbox Code Playgroud)

iphone video user-interface objective-c ios

18
推荐指数
2
解决办法
1万
查看次数

每隔一分钟运行JS功能

所以我有这个JavaScript时钟,我正在努力,我希望它与客户的系统时钟完全同步.我知道如何使用Date对象获取当前时间,我知道如何每60000毫秒(1分钟)运行更新功能.问题是客户端可能在半分钟已经过去时加载页面,使时钟滞后30秒.当分钟变量实际发生变化时,有没有办法只运行更新功能?(我只想要精确度.)

我如何获得当前时间:

var time = new Date();
var currentHour = time.getHours();
var currentMinute = time.getMinutes();
Run Code Online (Sandbox Code Playgroud)

我如何每60000毫秒运行更新功能:

setInterval(update,60000); //"update" is the function that is run
Run Code Online (Sandbox Code Playgroud)

javascript time function timing updates

1
推荐指数
2
解决办法
1966
查看次数