2
모바일 사파리의 탭 기능에있는보기 전환 기능을 복제하고 싶습니다. 그러나 뷰 스크린 샷을 포함하는 scrollview를 구현했습니다. 뷰를 선택하면 줌 애니메이션과 제목 및 툴바가 어떻게 나타나며 그 반대의 경우도 복제됩니까?iphone SDK로 사파리 탭보기 전환 기능을 복제하십시오.
모바일 사파리의 탭 기능에있는보기 전환 기능을 복제하고 싶습니다. 그러나 뷰 스크린 샷을 포함하는 scrollview를 구현했습니다. 뷰를 선택하면 줌 애니메이션과 제목 및 툴바가 어떻게 나타나며 그 반대의 경우도 복제됩니까?iphone SDK로 사파리 탭보기 전환 기능을 복제하십시오.
답변을 찾았으므로 공유하겠습니다.
- (void)clickHandler{
// create an image that looks exactly like
// the preview image in your scroll view (can leave off the toolbar/statusbar if you like)
UIImage *img = [UIImage imageNamed:@"something.png"];
// create an imageview to hold the image
UIImageView *iv = [[UIImageView alloc] initWithImage:img];
// ensure that the frame is set so that it's directly over the image in your scrollview
iv.frame = CGRectMake(60, 150, 200, 200);
// push the image into the superview over top this controller's view
[[self.view superview] insertSubview:iv aboveSubview:self.view];
// refresh superview NOW
[[self.view superview] performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:YES];
//-----------
//animate the image to bring it from it's "scrollview size" to the size it will be after the transition.
[UIImageView beginAnimations:nil context:nil];
[UIImageView setAnimationDuration:0.3];
iv.frame = CGRectMake(0, 65, 320, 371);
[UIImageView commitAnimations];
//-----------
// transition to the new view using the CrossDissolve transition (or just don't animate it.)
NewViewController *controller = [[NewViewController alloc] initWithNibName:@"NewView" bundle:nil];
controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:controller animated:YES];
[controller release];
// set the animated imageview to remove itself after a delay
// (after the new view is transitioned into place below it.)
[iv performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:0.3];
// be sure to release where needed and all that, I may have cut too much from the code for this snippet.
// this may not be the best example, but it does work.
// please post any improvements back so that we can all benefit
}