저는 autolayout없이 ViewController를 가지고 있고 일부 단추를 움직이려고합니다. ViewDidAppear에서 일부 UIView animateWithDuration 코드가 있고 거기의 모든 것이 훌륭하게 작동합니다. 그러나 뷰를 애니메이션으로 만들려고 할 때 아무 것도 움직이지 않습니다.animateWithDuration이 전혀 실행되지 않습니다
다음은 코드 시퀀스입니다. 버튼을 누르고 Facebook에 로그인 한 다음 [self doneWithLogin]이 호출되는 loginFacebook을 호출합니다. :
- (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 selector가 호출됩니다.
어떤 일이 벌어지고 있는지 알 수 있습니까?
어떤 방법이 안에 있습니까? 'viewWillDisappear'? 버튼 동작? – Can
@rmaddy 그래, 그리고 애니메이션은'viewDidAppear'에서 잘 작동한다고하지만, "애니메이션 아웃"에서는 그렇지 않다. 그래서 그는 그가 viewDidAppear 내부에서 호출하고 있다고 가정 할 것입니다. – Can
아니요, 해당 버튼 동작 – Spenciefy