버튼을 누르거나 무엇이든간에 내 앱에서 무언가를 요청하면 "로딩 .."이라는 작은 사각형이 나타나기를 원합니다. 완료되면 "슬라이드 업 효과"와 함께 사라집니다. 나는 달성하려는 것을 잘 묘사하기위한 간단한 모형을 만들었습니다. 나 한테 어떤 힌트가 있니? 감사.iPhone 로딩보기 "슬라이드 효과"
참고 : 내가 원하지 않는 효과를 당겨서 새로 고침 (로드 뷰는 코멘트를 보낼 때, 예를 들어 표시, 화면 스크롤없이 나타납니다)
UPDATE :
- (IBAction)displayLoadingScreen:(id)sender
{
NSLog(@"pressed");
UIView *loadingView = [[UIView alloc] init];
loadingView.frame = CGRectMake(0,-40,320,40);
[loadingView setBackgroundColor:[UIColor blueColor]];
[self.view addSubview:loadingView];
//animate in within some method called when loading starts
[UIView animateWithDuration:1.0
animations:^{
loadingView.frame = CGRectMake(0,0,320,40);
}
completion:^(BOOL finished) {
}];
for (int i = 0; i < 10000; i++) {
NSLog(@"%d", i);
}
//animate out within some method called when loading ends
[UIView animateWithDuration:1.0
animations:^{
loadingView.frame = CGRectMake(0,-40,320,40);
}
completion:^(BOOL finished){
}];
}
:
은 내가 권층운 코드를 시도했습니다
for 루프 이후에 로딩 뷰가 왜 에 들어 있습니까? 시도한 후에 for 루프를 인쇄하기 전에 두 애니메이션을 실행합니다. 아이디어?
UPDATE 2
- (void)stopLoading {
[UIView animateWithDuration:1.0
animations:^{
loadingView.frame = CGRectMake(0,-40,320,40);
}
completion:^(BOOL finished){
}];
}
- (void)startLoading {
loadingView.frame = CGRectMake(0,-40,320,40);
[loadingView setBackgroundColor:[UIColor blueColor]];
[self.view addSubview:loadingView];
//animate in within some method called when loading starts
[UIView animateWithDuration:1.0
animations:^{
loadingView.frame = CGRectMake(0,0,320,40);
}
completion:^(BOOL finished) {
}];
sleep(5);
[self stopLoading];
}
- (IBAction)displayLoadingScreen:(id)sender
{
NSLog(@"button pressed");
[self startLoading];
}
'UIAnimation' 클래스를 읽고 (그리고 QuartzCore 프레임 워크 사용) 시도해보십시오. – Raptor
페이스 북처럼 슬라이드 다운 기능을 사용하려면 'EGOTableViewPullRefresh'사용을 고려하십시오. – Raptor