0
我有一個多視圖應用程序,我已經構建了一個自定義的panelview控制器來顯示有關產品的信息有限的面板,問題是應該有3個面板縱向方面和4個橫向。移動UIScrollView旋轉在ipad上
由於視圖控制器的深度(約5)的didRotateFromInterfaceOrientation:
事件將不會對兒童的ViewController觸發,所以我使用NSNotificationCenter
上RootViewController的發佈的消息,並與子控制器採摘它。
我可以毫無困難地移動面板(UIScrollViews),但是當我想讓它們移動到位時,它們會立即移動,這不光滑或整齊,我希望它們滑入新的位置。
經過一番搜索,我仍然沒有找到如何做到這一點的運氣。
-(void) updatePanelLocations{
int buttonWidth = 230;
int buttonHeight = 335;
float frameWidth = mainPanel.frame.size.width;
int numberOfcolumns = frameWidth/buttonWidth;
float margin = (frameWidth - (numberOfcolumns * buttonWidth))/(numberOfcolumns +1);
int currentRow = 0;
int currentColumn = 0;
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setType:kCATransitionReveal];
[animation setDuration:0.4];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]];
int i = 0;
for (UIView* curView in [mainPanel subviews]) {
//set an arbutrary tag field in generating the scrollviews so i can detect this
if (curView.tag != 9991) continue;
//newline detection
if (currentColumn == numberOfcolumns){
currentRow++;
currentColumn = 0;
}
[[curView layer] addAnimation:animation forKey:@"transitionViewAnimation"];
//XY Coordinates
int buttonX = (margin * (currentColumn + 1)) + (buttonWidth * currentColumn);
int buttonY = (margin * (currentRow + 1)) + (buttonHeight * currentRow);
//make the frame
[curView setFrame:CGRectMake(buttonX, buttonY, buttonWidth, buttonHeight)];
[curView setAutoresizingMask: UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin];
//put the button on the target uiscrollview
[[curView layer] removeAnimationForKey:@"transitionViewAnimation"];
//next column
currentColumn++;
i++;
}
animation = nil;
}
如何動畫這個動作從a滑動到b?
或者更好的,如果我擁有了一切錯誤,指出我在正確的方向:)
乾杯
這真棒,真的很整齊,我的方法有所縮小。謝謝。 – 2011-06-01 23:39:21