I have a button on the view of iPhone built on mono touch.
When it is clicked, it fires an animation and then returns to the main animation.
Both animations are fired on an UIImageView which is on the same view where the button exists.
But it disappears when I click after two times?
I want the button always on the surface.
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;
}
}
}
}
That was my fault that I confess now:
It was because I remove subviews’ element . My purpose was controlling the unnecessary elements to be removed but the buttons was removed in that loop.
Thanks for your time.