나는 시작 직후에 재생되기를 원하기 때문에 viewDidLoad에 넣은 애니메이션 (이미지 배열)을 가지고 있습니다. viewDidLoad 애니메이션 후에도 UIWebView에서 webview를 보여주고 싶습니다. 애니메이션은 재생됩니다 (UIImage가 만들어지지 않은 이유가 있습니다).하지만 완료 후에는 제거 할 수 없습니다. 나는 타이머를 넣고 슈퍼 뷰에서 애니메이션을 제거하려고했지만 제거하는 대신 앱을 종료하고 메인 페이지로 돌아갑니다.완료 후 viewDidLoad에서 애니메이션 제거
-(void)viewDidLoad
{
UIImage *first = [UIImage imageNamed:@"panda1.png"];
animation = [[UIImageView alloc] initWithImage:first];
animation.animationImages = [NSArray arrayWithObjects: first,
[UIImage imageNamed:@"panda2.png"],
[UIImage imageNamed:@"panda3.png"], nil];
animation.animationRepeatCount = 4;
animation.animationDuration = 2;
[animation startAnimating];
[self.view addSubview:animation];
//set timer to remove animation from view
NSTimer *timer;
timer = [NSTimer scheduledTimerWithTimeInterval: 3
target: self
selector: @selector(removeAnimation:)
userInfo: nil
repeats: NO];
//for loading the image at start up
NSString *urlAddress = @"http://projects.seng.uvic.ca/most_recent.php";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//load the request in the UIWebView
[webView loadRequest:requestObj];
}
//removes the animation from subview
- (void) method: (NSTimer*) theTimer
{
[animation release];
[animation removeFromSuperview];
}
oops는 누락 된 함수 이름을 알지 못했습니다. (아직도이 mac 키보드에 익숙해 져 있습니다.) 함수 이름을 추가하면 내 문제가 해결되었습니다. – panda