首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >animateWithDuration根本不运行

animateWithDuration根本不运行
EN

Stack Overflow用户
提问于 2014-02-22 01:44:35
回答 1查看 148关注 0票数 0

我有一个没有自动输出的ViewController,我正在尝试动画一些按钮。我在UIView中有一些animateWithDuration代码,所有的代码都很好用。但是当我想要把风景动画化的时候,没有任何东西是有生命的。

这是代码序列。点击按钮,拨打loginFacebook,登录Facebook,然后调用self doneWithLogin。:

代码语言:javascript
复制
- (IBAction)loginFacebook:(id)sender {
        [self loginFacebook];
}

-(void)loginFacebook{
    //Login to Facebook to get name, photo

    NSArray *permissions = [[NSArray alloc] initWithObjects:
                            @"user_photos",
                            @"user_status",
                            nil];


       [FBSession openActiveSessionWithReadPermissions:permissions
                                       allowLoginUI:YES
                                  completionHandler:^(FBSession *session,
                                                      FBSessionState state,
                                                      NSError *error) {

                                      if(!error){

                                          [self getFacebookData];
                                      }
                                      if(error){

                                          UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Oops." message: @"Something went wrong with Facebook." delegate: nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
                                          [alert show];

                                      }

                                  }];

}

-(void)getFacebookData{
    if (FBSession.activeSession.isOpen) {
        [[FBRequest requestForMe] startWithCompletionHandler:
         ^(FBRequestConnection *connection,
           NSDictionary<FBGraphUser> *user,
           NSError *error) {
             if (!error) {

                 UserData *userData = [UserData sharedManager];
                 userData.userName = user.name;
                   NSString *photo = [NSString stringWithFormat:@"https://graph.facebook.com/%@/picture?type=square", user.username];

                 userData.userPhoto = photo;

                 //now store data in nsuserdefault
                 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];


                 [defaults setObject:userData.userName forKey:@"name"];
                 [defaults setObject:userData.userPhoto forKey:@"photo"];

                 [defaults synchronize];

                 //should show animations and user info
                 [self doneWithLogin];

             }
             if(error){
                                 UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Oops." message: @"Something went wrong with Facebook." delegate: nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
                 [alert show];

             }
         }];


    }


}

-(void)doneWithLogin{
[SVProgressHUD dismiss];
UserData *userData = [UserData sharedManager];
NSLog(@"done with login called");
   NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];


[defaults setObject:@"YES" forKey:@"loggedIn"];
[[NSUserDefaults standardUserDefaults] synchronize];


NSLog(@"animation starting");
[UIView animateWithDuration: 1.0f
                      delay: 0.0f
                    options: UIViewAnimationOptionCurveEaseIn
                 animations:^{
                     logo.alpha = 0.0;
                     facebookButton.alpha = 0.0;
                     twitterButton.alpha = 0.0;
                     guestButton.alpha = 0.0;

                     NSLog(@"animation started");
                 }
                 completion:^(BOOL finished){
                     statusLabel.numberOfLines = 2;
                     statusLabel.lineBreakMode = NSLineBreakByWordWrapping;
                     statusLabel.text = [NSString stringWithFormat:@"Have a good time, %@", userData.userName];
                     [UIView animateWithDuration: 0.7f
                                            delay: 0.0f
                                          options: UIViewAnimationOptionCurveEaseIn
                                       animations:^{

                                           statusLabel.alpha = 1.0;
                                       }
                                       completion:^(BOOL finished){
                                           [self performSelector:@selector(dismissView:) withObject:self afterDelay:1];

                                       }
                                ];
                 }];

}

动画开始日志出现,但动画启动日志没有。没有动画,然后在一段时间后,dismissView选择器被调用。

知道怎么回事吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-22 05:20:31

你确定你在doneWithLogin的主队列上吗?我对FB并不熟悉,但是当我看到不稳定的UIKit代码时,这是我首先检查的事情之一。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21948540

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档