Creating a app.-Need a little help

Discussion in 'Jiggy Runtime Development' started by e.mann30, Jun 10, 2008.

  1. e.mann30

    e.mann30 New Member

    Joined:
    Nov 13, 2007
    Messages:
    427
    Likes Received:
    8
    Ok , I've been working on this app. and now i'm stuck. I need to know how to have a button function in the navbar to take me to a new Main page. Its like I have a start up page with info , and now I need to go from that page to a new page with the press of a button on the nave bar. Any help will do. Thanks.
  2. OneFan

    OneFan Active Member

    Joined:
    Feb 25, 2008
    Messages:
    949
    Likes Received:
    67
    Device:
    iPhone 4 (White)
    IM NOT SURE IF I DID WHAT YOU ASKED BUT I THINK I MIGHT OF DONE WHAT YOU ASKED. JUST TAKE A LOOK AT THIS AND CUT AND PASTE IT INTO OUR APP.

    OTHERWISE IF THIS DOESN THELP PM ME SOME OF YOUR CODE AND I WILL HELP.


    Code:
    Plugins.load( "UIKit" );
    
    var itemOne = new UINavigationItem( "TEST" );
    var itemTwo = new UINavigationItem( "" );
    
    var window = new UIWindow( UIHardware.fullScreenApplicationContentRect );
    window.setHidden( false );
    window.orderFront();
    window.makeKey();
    window.backgroundColor = [ 1 , 1 , 1 , 1 ];
    
    var tview = new UITransitionView( window.bounds );
    
    window.setContentView( tview );
    
    var bar = new UINavigationBar( [ 0 , 0 , window.bounds[ 2 ] , 44 ] );
    bar.showButtonsWithStyle( null , 0 , null , 0 );
    
    var setbar = new UINavigationBar( [ 0 , 0 , window.bounds[ 2 ] , 44 ] );
    setbar.showButtonsWithStyle( "BACK" , 2 , "NEXT", 0 );
    
    var ptable = new UIPreferencesTable( [ 0 , 44 , 320 , 460-44 ] , tview.bounds );
    
    ptable.onGetNumberOfGroups = function( tbl )
    {
      return 1;
    }
    
    ptable.onGetNumberOfRowsInGroup = function( tbl , group )
    {
      switch( group )
      {
        case 0 : return 1;
      }
    }
    
    ptable.onIsLabelGroup = function( tbl , group )
    {
      switch( group )
      {
        case 0 : return false;
      }
    }
    
    var titleCells = [];
    
    var titleCell;
    
    titleCell = new UIPreferencesTableCell();
    titleCell.title = "Page One";
    
    titleCells.push( titleCell );
    
    ptable.onGetCellForGroup = function( tbl , group )
    {
      if ( group >= 0 && group < titleCells.length )
        return titleCells[ group ];
      else
        return null;
    };
    
    ptable.onGetHeightForRow = function( tbl , group , row , proposedHeight )
    {
      if ( row == -1 )
      {
        return 40;
      }
      return proposedHeight;
    };
    
    ptable.onShowDisclosureForRow = function( tbl , row )
    {
      if ( row == 1)
      {
      return true;
      }
      else
      {
      return false;
      }
    }
    
    var cells = [ [] , [] , [] ];
    
    var cell;
    var control;
    
    cell = new UIPreferencesControlTableCell();
    cell.title = "Page One";
    cell.setEnabled( true );
    cell.showSelection = false;
    cells[0].push( cell );
    cell.onTap = function()
    {
    setbar.pushNavigationItem( itemTwo );
    tview.transitionFrom( 1 , blueView , redView );
    }
    
    ptable.onGetCell = 
      function( tbl , group , row )
      {
        return cells[ group ][ row ];
      };
      
    ptable.reloadData();
    
    
    var conftable = new UIPreferencesTable( [ 0 , 44 , 320 , 460-44 ] , tview.bounds );
    
    conftable.onGetNumberOfGroups = function( tbl )
    {
      return 1;
    }
    
    conftable.onGetNumberOfRowsInGroup = function( tbl , group )
    {
      switch( group )
      {
        case 0 : return 1;
      }
    }
    
    conftable.onIsLabelGroup = function( tbl , group )
    {
      switch( group )
      {
        case 0 : return false;
      }
    }
    
    var titleCellst = [];
    
    var titleCellt;
    
    titleCellt = new UIPreferencesTableCell();
    titleCellt.title = "Page Two";
    
    titleCellst.push( titleCellt );
    
    conftable.onGetCellForGroup = function( tbl , group )
    {
      if ( group >= 0 && group < titleCells.length )
        return titleCellst[ group ];
      else
        return null;
    };
    
    conftable.onGetHeightForRow = function( tbl , group , row , proposedHeight )
    {
      if ( row == -1 )
      {
        return 40;
      }
    
      return proposedHeight;
    };
    
    conftable.onShowDisclosureForRow = function( tbl , row )
    {
      if ( row == 1)
      {
      return false;
      }
      else
      {
      return false;
      }
    }
    
    var tcells = [ [] , [] , [] ];
    
    var tcell;
    
    tcell = new UIPreferencesControlTableCell();
    tcell.title = "Page Two";
    tcell.setEnabled( true );
    tcell.showSelection = false;
    tcells[0].push( tcell );
    
    conftable.onGetCell = 
      function( tbl , group , row )
      {
        return tcells[ group ][ row ];
      };
      
    conftable.reloadData();
    
    var blueView = new UIView( tview.bounds );
    blueView.backgroundColor = [ 0 , 0 , 1 , 1 ];
    
    var redView = new UIView( tview.bounds );
    redView.backgroundColor = [ 1 , 0 , 0 , 1 ];
    
    tview.transition( 0 , blueView );
    
    blueView.addSubview( ptable );
    redView.addSubview( conftable );
    
    bar.pushNavigationItem( itemOne );
    setbar.pushNavigationItem( itemTwo );
     
    blueView.addSubview( bar );
    redView.addSubview( setbar );
    
    setbar.onButtonClicked = function( bar , button )
    {
      if ( button == 1 )
      {
      tview.transitionFrom( 2 , redView , blueView );
      blueView.addSubview( ptable );
      }
      {
      if ( button == 2 )
      {
      tview.transitionFrom( 2 , redView , blueView );
      blueView.addSubview( ptable );
      }
      }
      }; 
  3. carboycam

    carboycam New Member

    Joined:
    Feb 20, 2008
    Messages:
    43
    Likes Received:
    0
    You used the code from my help thread. *gulp* Not the greatest thing to use as an example.

    Please Register or Log in to view images



    Where it's got 'cellst' and 'cellt' the t is there so the app doesn't get confused between the two preference tables.

    Please Register or Log in to view images

  4. e.mann30

    e.mann30 New Member

    Joined:
    Nov 13, 2007
    Messages:
    427
    Likes Received:
    8
    thanks


    This was going to be my second question about adding cells to a mainView page. I figured out my own question out. Thanks for the help. If I have anymore question I will post them here insted of starting a new thread. Making apps is fun.
  5. carboycam

    carboycam New Member

    Joined:
    Feb 20, 2008
    Messages:
    43
    Likes Received:
    0
    Good luck with the App.

    Please Register or Log in to view images



    If I was to say what you said to anyone I know, they'd look at me funny, and probably give me a good slap.

    Please Register or Log in to view images

    But yeah, creating Apps is fun... as long as you can solve the syntax errors.

    Please Register or Log in to view images

  6. e.mann30

    e.mann30 New Member

    Joined:
    Nov 13, 2007
    Messages:
    427
    Likes Received:
    8
    More trouble

    My app is coming along fine. I don't want to give a name or what it will be yet because I don't see it here on the forums yet. When I think its complete enough to give out i will release it. I'm still very much a noob at making apps. I've just been reading everything on jiggy and so far I'm getting the hang of it.

    Well the point of this post is that i'm stuck again with one of the buttons on the navbar. I have two buttons , the one on the left is the "about" button , the other leads you to another page. Ok, on the about button I added a new UIAlertSheet with title and body text. Ok this works fine when I press the about button , but then it just stays on the screen and I cannot return to the mainView. My setup looks like this


    bar.pushNavigationItem( itemOne );

    bar.onButtonClicked =
    function( theBar , theButton )

    {
    if ( theButton == 1 )
    {
    var eman = new UIAlertSheet( [0 , 0, 200, 60] , 0 );
    eman.setAlertSheetStyle(9);
    eman.setTitle( "About" );
    eman.setBodyText( "Created by emann.30." );
    eman.presentSheetFromAboveView( mainView );

    When I press the about button, I want the person to read the info then return to the mainView screen when finished. I tried adding eman.dismiss ( true ) , but when you press the about button it pops up quick then goes away. Any help please.
  7. carboycam

    carboycam New Member

    Joined:
    Feb 20, 2008
    Messages:
    43
    Likes Received:
    0
    Here's the layout for the 'About' Alert Sheet in my App:

    Code:
    var about = new UIAlertSheet( "TITLE" , [ ] , 1 );
    about.setBodyText( "Main Text" );
    about.setAlertSheetStyle( 0 );
    about.onTap = function()
    {
    about.dismiss( true ); // Close Alert Sheet
    }
    There are no buttons displayed on the Sheet, but one tap on the screen, and it disappears!

    Please Register or Log in to view images

  8. PAEz

    PAEz New Member

    Joined:
    Jan 29, 2008
    Messages:
    201
    Likes Received:
    10
  9. e.mann30

    e.mann30 New Member

    Joined:
    Nov 13, 2007
    Messages:
    427
    Likes Received:
    8
    thank you

    I want to thank you guys for helping me.
  10. PAEz

    PAEz New Member

    Joined:
    Jan 29, 2008
    Messages:
    201
    Likes Received:
    10
    In that code OneFan gave you get rid of line 95...
    setbar.pushNavigationItem( itemTwo );
    ....it causes an error...you cant set the title for the second view if that lines still there..you can set that here...
    var itemTwo = new UINavigationItem( "" );
    ...change it to whateva....
    var itemTwo = new UINavigationItem( "Page Two" );

    You also dont need lines 210 or 216

    PS I also find codeing fun....I struggle with it alot, but thats what makes it so satisfying when i get it right

Share This Page