zoukankan      html  css  js  c++  java
  • ios4动画 转自cocoachina

    ios4使用MoviePlayer播放横屏动画   

    最近要加一个横屏的片头动画到程序里,使用MPMoviePlayerController
    在IOS4上使用这个类播放动画与3.x sdk 的比有一些改变


    我一般直接加在AppDelegate.m里

    - (void)applicationDidFinishLaunching:(UIApplication *)application
    {
    NSString*moviePath = [[NSBundlemainBundle] pathForResource:@"introMovie"ofType:@"m4v"];
    NSURL *movieURL = [NSURL fileURLWithPath:moviePath];

    MPMoviePlayerController*theMovie = [[MPMoviePlayerControlleralloc]initWithContentURL:movieURL];
    theMovie.scalingMode= MPMovieScalingModeAspectFill;  

    //下面是IOS4与3.x sdk不一样的地方 
    // +++

    //theMovie = MPMovieControlModeHidden;是以前的sdk用的,现在建议用下面这句
    theMovie.controlStyle= MPMovieControlStyleNone; //os 4.0

    theMovie.view.frame = CGRectMake(0, 0, 480, 320); 

    //4.0里需要我们把MPMoviePlayerControll顺时针转90度,并且把controller的view加到UIWindow或者UIView对象里
    //3.x 里不用做这些就能实现同样的效果

    CGAffineTransform landscapeTransform;
    landscapeTransform = CGAffineTransformMakeRotation(90 * M_PI / 180);
    landscapeTransform = CGAffineTransformTranslate(landscapeTransform, 80, 80);
    [theMovie.view setTransform:landscapeTransform];


    [window addSubview: theMovie.view]; 
    [windowmakeKeyAndVisible];
    //IOS4与3.x sdk不一样的地方 // ---

    //Register for the playback finished notification.
    [[NSNotificationCenterdefaultCenter] addObserver:self
    selector:@selector(movieFinishedCallback:)
    name:MPMoviePlayerPlaybackDidFinishNotification
    object:theMovie];
    [theMovie play];




    }

    //放完动画了进入程序。添加其它的view
    -(void)movieFinishedCallback:(NSNotification *)aNotification
    {
    MPMoviePlayerController *theMovie = [aNotification object];
    [[NSNotificationCenterdefaultCenter] removeObserver:self
    name:MPMoviePlayerPlaybackDidFinishNotification
    object:theMovie];
    [theMovie release];

    [windowaddSubview:viewController.view];
    [windowmakeKeyAndVisible];
    }

  • 相关阅读:
    外部无法捕捉Realm的doGetAuthenticationInfo方法抛出的异常
    Redis多实例及主从搭建
    Redis安装
    window.showModalDialog两次加载问题清除缓存方法
    JQuery分页插件bs_pagination的应用
    解决IE11出现异常SCRIPT5011:不能执行已释放Script的代码
    通过CSS禁用页面模块的复制和粘贴功能
    C# toString()转换详细(转)
    百度ue富文本编辑器setContent方法报错初始化加载内容失败解决办法
    前端页面div float 后高度 height 自适应的问题
  • 原文地址:https://www.cnblogs.com/chenfulai/p/2287622.html
Copyright © 2011-2022 走看看