gpt4 book ai didi

ios - animateWithDuration 根本没有运行

转载 作者:行者123 更新时间:2023-11-29 03:13:36 34 4
gpt4 key购买 nike

我有一个没有自动布局的 ViewController,我正在尝试为一些按钮设置动画。我在 ViewDidAppear 中有一些 UIView animateWithDuration 代码,那里的一切都很好。但是当我想为 View 设置动画时,没有任何动画。

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

- (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 选择器。

知道发生了什么吗?

最佳答案

您确定您在 doneWithLogin 的主队列中吗?我不熟悉 FB API,但当我看到简单的 UIKit 代码时,这是我检查的第一件事。

关于ios - animateWithDuration 根本没有运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21948540/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com