2次点击后按钮消失(单声道触摸 - iPhone)

时间:2012-11-21 22:18:37

标签: c# iphone uiview xamarin.ios

我在单声道触控上构建的iPhone视图上有一个按钮。 单击它时,它会触发动画,然后返回主动画。 两个动画都在UIImageView上触发,该视图位于按钮所在的同一视图上。

但是当我两次点击后它会消失吗? 我希望按钮始终在表面上。

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;
            }
        }
    }
}

1 个答案:

答案 0 :(得分:0)

我现在承认这是我的错: 这是因为我删除了子视图的元素。我的目的是控制要删除的不必要元素,但在该循环中删除了按钮。

感谢您的时间。