NimbleKit - fast iOS app development

NKMoveToPageAnimated to same page => black screen

Problem discussions

NKMoveToPageAnimated to same page => black screen

Postby Tscherno » Sun May 22, 2011 12:00 pm

Hi,

i'm trying to use NKMoveToPageAnimated("main.html","CurlUp"); to animate the reload of the main page. Curl happens, but then the app just turns black. Any hints?

Code:
Code: Select all
<html>
<head>
<meta name = "viewport" content = "initial-scale = 1.0, user-scalable = no" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="style.css">
   
<script type="text/javascript" src="NKit.js"></script>
    <script>
        function OnTouchStart(event)
        {
            var touch = event.touches[0];
            initialTouchPosition = touch.pageX;
            initialTouchPositionY = touch.pageY;
        }
       
        function OnTouchEnd(event)
        {
            if (((lastPosition-initialTouchPosition)) > 100 || ((lastPositionY-initialTouchPositionY)) > 50 )
            {
                //location.reload();
                NKMoveToPageAnimated("main.html","CurlUp");
            }
           
            if (((lastPosition-initialTouchPosition)) < -100 || ((lastPositionY-initialTouchPositionY)) < -50)
            {
                //location.reload();
                NKMoveToPageAnimated("main.html","CurlUp");
            }
        }
       
        function OnTouchMove(event)
        {
            var touch = event.touches[0];
            lastPosition = touch.pageX;
            lastPositionY = touch.pageY;   

        }
        </script>
   


</head>
<body ontouchmove="OnTouchMove(event);"  ontouchstart="OnTouchStart(event);" ontouchend="OnTouchEnd(event);"]]>

    <script type="text/javascript">
        var database = new NKSQLite();
        database stuff...
        database.closeDatabase();
        </script>
   
</body>
</html>
Tscherno
 
Posts: 15
Joined: Fri Jul 09, 2010 12:50 pm

Re: NKMoveToPageAnimated to same page => black screen

Postby Big-O » Mon May 23, 2011 5:42 pm

The code look ok to me though I've never tried to do that so I don't know if that's supported or not. I would try making a blank project and doing nothing but the curlup to find out if that's the issue or of there is something else in your code causing the problem.

The black screen usually means there's a javascript error and you should be able to use NKlog to pin point the exact spot that's happening.
-- Big-O
-- Nimblekit Guru, Web Developer, Hopeless Geek

I do freelance!
http://realisticweb.com
User avatar
Big-O
NimbleKit Guru
 
Posts: 1231
Joined: Thu Sep 24, 2009 4:02 am

Re: NKMoveToPageAnimated to same page => black screen

Postby Tscherno » Mon May 23, 2011 5:47 pm

There isn't anything else in it. I created a copy of the page and switch from main.html to main2.html and back, this is working.
Tscherno
 
Posts: 15
Joined: Fri Jul 09, 2010 12:50 pm

Re: NKMoveToPageAnimated to same page => black screen

Postby ryubr » Mon May 23, 2011 8:11 pm

Tscherno wrote:There isn't anything else in it. I created a copy of the page and switch from main.html to main2.html and back, this is working.


From my experience, every time you load a page you already loaded like this it goes black. For instance I have a page then I use the navcontroller gotoPage method on one page to go to the page A.html, then, without leave (goBack from A.html) I navigate to the page "C.html" and there I try to go to the "A.html" it goes black. I just added a param to my URL, usually a random number and then everything works fine :-)
ryubr
NimbleKit Expert
 
Posts: 445
Joined: Fri Jun 19, 2009 5:36 am

Re: NKMoveToPageAnimated to same page => black screen

Postby Tscherno » Mon May 23, 2011 8:14 pm

No that worked: Going from A to B without parameters. Only problem: Pages don't refresh when called that way. I also added the random number now. Problem with that is, that you see a blank page first and then it gets the content. Cannot precache it. Any idea?
Tscherno
 
Posts: 15
Joined: Fri Jul 09, 2010 12:50 pm

Re: NKMoveToPageAnimated to same page => black screen

Postby Big-O » Mon May 23, 2011 9:08 pm

Tscherno wrote:No that worked: Going from A to B without parameters. Only problem: Pages don't refresh when called that way. I also added the random number now. Problem with that is, that you see a blank page first and then it gets the content. Cannot precache it. Any idea?


They aren't refreshed because they are cached. You can refresh in the onpageshown event to get around that. The white page is because it's NOT cached. If you want to preload it you'd have to do it WITH the chosen random parameter too.
-- Big-O
-- Nimblekit Guru, Web Developer, Hopeless Geek

I do freelance!
http://realisticweb.com
User avatar
Big-O
NimbleKit Guru
 
Posts: 1231
Joined: Thu Sep 24, 2009 4:02 am

Re: NKMoveToPageAnimated to same page => black screen

Postby sunny » Tue May 24, 2011 10:08 am

the smoothest way to do that will be to have 2 pages and when you want to do refresh you use DOM to refresh the content on the second page and then make transition to that page. Making transition from one page to itself even with parameters is not a good idea because it is a workaround, but generally this should not even work at all, because to make animation you need to pages always, if you provide parameters then temporary page is created which takes part in transition, but really it's a waste of performance. Here I attach the example of refreshing pages without loosing performance (at least 10 times faster then reloading, on heavy pages with a lot of js includes it's hundreds times faster).
Attachments
refreshSample.zip
(22.61 KiB) Downloaded 104 times
User avatar
sunny
Staff
 
Posts: 2666
Joined: Sat May 30, 2009 5:18 am
Location: Palo Alto, California


Return to Troubleshooting

Who is online

Users browsing this forum: No registered users and 0 guests