2012-11-21 103 views
0

我在單聲道觸摸上構建的iPhone視圖上有一個按鈕。 點擊後,它會觸發動畫,然後返回到主動畫。 這兩個動畫都是在UIImageView上觸發的,該UIImageView位於存在按鈕的相同視圖上。按鈕在2次點擊後消失(單聲道觸摸 - iPhone)

但是當我點擊兩次後它消失了嗎? 我希望按鈕始終在表面上。

partial void TurnLightOnOrOff (MonoTouch.Foundation.NSObject sender) 
     { 
      TAMAM.coreLife.SwitchLightsStatus(); 
      dayPartType = DayPart.CurrentDayPart(); 
      if (dayPartType != DayPart.DayPartType.Night) { 
       playMainAnim(); 
       return; 
      } 
      var sound = SystemSound.FromFile (@"sound/Click.caf"); 
      sound.PlaySystemSound(); 

      if (!TAMAM.coreLife.LightsOn) { 

       myImages = new List<UIImage>(); 
       myImages.Add (UIImage.FromFile (@"image/babysleep/babysleeplightoff10000.png")); 
       myImages.Add (UIImage.FromFile (@"image/babysleep/babysleeplightoff20000.png")); 
       myImages.Add (UIImage.FromFile (@"image/babysleep/babysleeplightoff30000.png")); 
      var myAnimatedView = new UIImageView (this.animFrameRectangle); 
       myAnimatedView.AnimationImages = myImages.ToArray(); 
       myAnimatedView.AnimationDuration = 1; // Seconds 
       myAnimatedView.AnimationRepeatCount = 0; // 0 = Loops Forever 
       myAnimatedView.StartAnimating(); 
       if (this.svBabyAge.Subviews.Length > 0) { 
        this.svBabyAge.Subviews [0].RemoveFromSuperview(); 
       } 
       if(this.ivBabyAge.Subviews.Length > 0) 
       { 
        this.ivBabyAge.Subviews [0].RemoveFromSuperview(); 
       } 
       this.ivBabyAge.AddSubview (myAnimatedView); 
       this.svBabyAge.AddSubview (this.ivBabyAge); 

      } else { 
       playMainAnim(); 
      } 

     } 

{

[Register ("babyAge")] 
    partial class babyAge 
    { 
     [Outlet] 
     MonoTouch.UIKit.UIView svBabyAge { get; set; } 

     [Outlet] 
     MonoTouch.UIKit.UIImageView ivBabyAge { get; set; } 

     [Outlet] 
     MonoTouch.UIKit.UIButton butonInformation { get; set; } 

     [Action ("ShowInformationAboutTamagotchiStatus:")] 
     partial void ShowInformationAboutTamagotchiStatus (MonoTouch.Foundation.NSObject sender); 

     [Action ("FeedBaby:")] 
     partial void FeedBaby (MonoTouch.Foundation.NSObject sender); 

     [Action ("PlayWithBaby:")] 
     partial void PlayWithBaby (MonoTouch.Foundation.NSObject sender); 

     [Action ("TurnLightOnOrOff:")] 
     partial void TurnLightOnOrOff (MonoTouch.Foundation.NSObject sender); 

     [Action ("Dance:")] 
     partial void Dance (MonoTouch.Foundation.NSObject sender); 

     [Action ("DoctorRepairBaby:")] 
     partial void DoctorRepairBaby (MonoTouch.Foundation.NSObject sender); 

     [Action ("DoWc:")] 
     partial void DoWc (MonoTouch.Foundation.NSObject sender); 

     void ReleaseDesignerOutlets() 
     { 
      if (svBabyAge != null) { 
       svBabyAge.Dispose(); 
       svBabyAge = null; 
      } 

      if (ivBabyAge != null) { 
       ivBabyAge.Dispose(); 
       ivBabyAge = null; 
      } 

      if (butonInformation != null) { 
       butonInformation.Dispose(); 
       butonInformation = null; 
      } 
     } 
    } 
} 
+0

請提供一些代碼。 –

+0

TurnLightOnOrOff被點擊兩次,然後其按鈕消失 – theklc

+1

此外,與你的問題無關的東西。你可以通過使用集合初始化能力刪除幾條'.Add'行...... http://www.dotnetperls.com/initialize-list – Jared

回答

0

那是我的錯,我現在承認: 那是因爲我刪除子視圖元素。我的目的是控制不必要的元素被刪除,但在該循環中刪除了按鈕。

謝謝你的時間。

相關問題