2010-08-12 28 views
0

我在我的一個頁面上有一個UISegmentedControl。我想要一個編輯框出現在點擊段下方的點擊段。我想它是動畫(幻燈片或東西)UISegmentedControl定製

這可能嗎?什麼是最好的方法來做到這一點?

該死的。我忘了提及所有這些行動將發生在一個單元格內而不是一個簡單的視圖。

回答

1

你可以試試UIView動畫。 首先將你的編輯框(UITextView,我猜??)到x座標320(所以它不會出現)。 其次,當用戶打分段控制使用的UIView動畫只是翻譯你的UITextView:

[UIView beginAnimation:nil context:nil]; 
[UIView setAnimationDuration: 1.0]; 
CGAffineTransform trans = CGAffineTransformMakeTranslation(-320, 0); 
self.view.transform = trans; 
[UIView commitAnimations]; 

希望它會幫助你)。

+0

日Thnx ... 進出口新的這個東西(1周月的經歷)。我理解的邏輯,但不知道在哪裏做的動畫,尤其是因爲這裏面發生的事情cellview – humblePilgrim 2010-08-12 08:48:58

0

好的,所以我會盡量做得更精確,我猜你正在使用Interface Builder? 所以,你必須「鏈接」的行動,你UISegmentedController,所以在你的類寫這個方法:

-(IBAction) translateMyView 
{ 
    //If the first segment is selected do translation of the cellView 
    if(yourSegmentedController.selectedSegmentIndex == 0) 
    { 
    [UIView beginAnimation:nil context:nil]; 
    [UIView setAnimationDuration: 1.0]; 
    //This will translate the view to its position from its position -320 px 
    CGAffineTransform trans = CGAffineTransformMakeTranslation(-320, 0); 
    //Replace self.view with the view you want to translate. 
    self.view.transform = trans; 
    [UIView commitAnimations]; 
    } 
    else if(yourSegementedController.selectedSegmentIndex ==1) 
    { 
    //Do same thing that above but with another view 
    } 
} 

所以這是occure動作,當你選擇你的segmentedController的索引。 你需要做的是將這個動作鏈接到Interface Builder中的UISegmentedController。

希望這將是有益的;-)

+0

似乎需要精確的人 一個表格視圖,其中的每個單元格包含一個分段控件,每個星期的每一天都有一個分段(總共7個分段)。我希望文本框在一天之下出現,當它的段被按下時,用戶可以在其中輸入他的數據。因爲表中可以有任意數量的單元格(都有自己的UISegmentedControls),問題就變得複雜了。 我準備轉儲動畫部分,但TextView必須出現在相應的日子之下。 – humblePilgrim 2010-08-12 10:29:10

+0

並通過編輯框我的意思是TextField不TextView – humblePilgrim 2010-08-12 10:46:24

+0

Thnx爲您付出的努力幫助我 – humblePilgrim 2010-08-12 10:47:04