1

これは、前のビューでボタンをクリックすると表示されるビューです。テキスト ボックス、笑顔の画像、およびラベルは、xCode によって事前に作成されたものです。

ビューの画像とコードを見て、ビューのすべてのコンポーネントの初期化が非常に遅く、完全にロードされたときに私がキャプチャした最後の撮影を行う準備をしている理由を明確にしてください。さらに、文字を入力すると非常に遅くなります。テキスト ボックスをタッチするたびに iOS が提供するキーボードで入力している間、文字の表示が非常に遅くなります。

ここに画像の説明を入力

ビューのコード;

using System;
using System.Drawing;

using MonoTouch.Foundation;
using MonoTouch.UIKit;

namespace IstanbulCity
{
    public partial class AskForNAme : UIViewController
    {
        public delegate void AskForNAmeClosingDelegate (AskForNAme form);

        public event AskForNAmeClosingDelegate AskForNAmeClosed;
        NSObject obs1;
        float scrollamount = 0.0f;
        float bottomPoint = 0.0f;
        float yOffset = 0.2f;
        bool moveViewUp = false;

        public AskForNAme () : base ("AskForNAme", null)
        {


        }

        public override void DidReceiveMemoryWarning ()
        {
            // Releases the view if it doesn't have a superview.
            base.DidReceiveMemoryWarning ();

            // Release any cached data, images, etc that aren't in use.
        }

        public override void ViewDidLoad ()
        {
            base.ViewDidLoad ();


            // Perform any additional setup after loading the view, typically from a nib.
        }
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(true);
                obs1 = NSNotificationCenter.DefaultCenter.AddObserver (
"UIKeyboardDidShowNotification", KeyboardUpNotification);
            this.tbOwnerMailAdress.ShouldReturn += TextFieldShouldReturn;
            this.tbOwnerBirthDay.ShouldReturn += TextFieldShouldReturn;
            this.uivGuguPhoto.Image = UIImage.FromFile ("image/fcuk.jpeg");

        }
        public override void ViewWillAppear(bool animated)
        {  
            base.ViewWillAppear(false);
            obs1 = NSNotificationCenter.DefaultCenter.AddObserver (
"UIKeyboardDidShowNotification", KeyboardUpNotification);
            this.tbOwnerMailAdress.ShouldReturn += TextFieldShouldReturn;
            this.tbOwnerBirthDay.ShouldReturn += TextFieldShouldReturn;
            this.uivGuguPhoto.Image = UIImage.FromFile ("image/fcuk.jpeg");

        }
        public override void ViewDidUnload ()
        {
            base.ViewDidUnload ();

            // Clear any references to subviews of the main view in order to
            // allow the Garbage Collector to collect them sooner.
            //
            // e.g. myOutlet.Dispose (); myOutlet = null;

            ReleaseDesignerOutlets ();
        }

        public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
        {
            // Return true for supported orientations
            return (toInterfaceOrientation != UIInterfaceOrientation.PortraitUpsideDown);
        }

        void HandleIstanbulCityViewControllerClosed (babyAge form)
        {
            form.DismissModalViewControllerAnimated (true);
            form = null;
        }



        partial void tbKadikoyHallEditDidEndOnExit (MonoTouch.Foundation.NSObject sender)
        {
            tbIstanbulName.ResignFirstResponder ();
        }



        private bool TextFieldShouldReturn (UITextField tf)
        {
            tf.ResignFirstResponder ();
            if (moveViewUp) {
                ScrollTheView (false);
            }
            return true;
        }

        private void KeyboardUpNotification (NSNotification notification)
        {
            ResetTheView ();

            RectangleF r = UIKeyboard.BoundsFromNotification (notification);

            if (this.tbOwnerMailAdress.IsEditing ) {
                //Calculate the bottom of the Texbox
                //plus a small margin...
                bottomPoint = (this.tbOwnerMailAdress.Frame.Y + this.tbOwnerMailAdress.Frame.Height + yOffset);

                //Calculate the amount to scroll the view
                //upwards so the Textbox becomes visible...
                //This is the height of the Keyboard -
                //(the height of the display - the bottom
                //of the Texbox)... 
                scrollamount = (r.Height - (View.Frame.Size.Height - bottomPoint));
            }
            else if (this.tbOwnerBirthDay.IsEditing)
            {
                bottomPoint = (this.tbOwnerBirthDay.Frame.Y + this.tbOwnerBirthDay.Frame.Height + yOffset);
                scrollamount = (r.Height - (View.Frame.Size.Height - bottomPoint));
            }
            else
            {
                scrollamount = 0;
            }

            //Check to see whether the view
            //should be moved up...
            if (scrollamount > 0) {
                moveViewUp = true;
                ScrollTheView (moveViewUp);
            }  else
                moveViewUp = false;
        }

        private void ResetTheView ()
        {
            UIView.BeginAnimations (string.Empty, System.IntPtr.Zero);
            UIView.SetAnimationDuration (0.3);

            RectangleF frame = View.Frame;
            frame.Y = 0;
            View.Frame = frame;
            UIView.CommitAnimations ();
        }

        private void ScrollTheView (bool movedUp)
        {
//To invoke a views built-in animation behaviour,
//you create an animation block and
//set the duration of the move...
//Set the display scroll animation and duration...
            UIView.BeginAnimations (string.Empty, System.IntPtr.Zero);
            UIView.SetAnimationDuration (0.3);

//Get Display size...
            RectangleF frame = View.Frame;

            if (movedUp) {
//If the view should be moved up,
//subtract the keyboard height from the display...
                frame.Y -= scrollamount;
            }  else {
//If the view shouldn't be moved up, restore it
//by adding the keyboard height back to the original...
                frame.Y += scrollamount;
            }

//Assign the new frame to the view...
            View.Frame = frame;

//Tell the view that your all done with setting
//the animation parameters, and it should
//start the animation...
            UIView.CommitAnimations ();

        }
    }
}

最近のバージョン - まだ同じユーザー エクスペリエンスが遅い!

using System;
using System.Drawing;

using MonoTouch.Foundation;
using MonoTouch.UIKit;

namespace IstanbulCity
{
    public partial class AskForNAme : UIViewController
    {
        public delegate void AskForNAmeClosingDelegate (AskForNAme form);

        public event AskForNAmeClosingDelegate AskForNAmeClosed;


        public AskForNAme () : base ("AskForNAme", null)
        {


        }

        public override void DidReceiveMemoryWarning ()
        {
            // Releases the view if it doesn't have a superview.
            base.DidReceiveMemoryWarning ();

            // Release any cached data, images, etc that aren't in use.
        }

        public override void ViewDidLoad ()
        {
            base.ViewDidLoad ();


            // Perform any additional setup after loading the view, typically from a nib.
        }


        public override void ViewDidUnload ()
        {
            base.ViewDidUnload ();

            // Clear any references to subviews of the main view in order to
            // allow the Garbage Collector to collect them sooner.
            //
            // e.g. myOutlet.Dispose (); myOutlet = null;

            ReleaseDesignerOutlets ();
        }

        public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
        {
            // Return true for supported orientations
            return (toInterfaceOrientation != UIInterfaceOrientation.PortraitUpsideDown);
        }

        void HandleIstanbulCityViewControllerClosed (babyAge form)
        {
            form.DismissModalViewControllerAnimated (true);
            form = null;
        }







    }
}
4

1 に答える 1

2

これは初期化に関連しているようには見えません。ViewDidAppearとの両方からの通知を追加していViewWillAppearます。また、すべてのキーボード通知で、アニメーションを行う を常に呼び出していますResetTheView(他に何も変更されていない場合でも)。

私の推測では、あなたがResetTheView認識しているよりも頻繁に呼び出しを行っていると思います.また、継続的なアニメーションがアプリケーションのパフォーマンスを低下させています.

これを確認するConsole.WriteLineには、メソッドに と、場合によってはカウンターを入れResetTheViewます。

于 2012-04-09T18:51:16.243 に答える