EzDevInfo.com

navigation interview questions

Top navigation frequently asked interview questions

How to hide 'Back' button on navigation bar on iPhone?

I added a navigation control to switch between views in my app. But some of the views shouldn't have 'Back' (the previous title) button. Any ideas about how to hide the back button?


Source: (StackOverflow)

Should I use window.navigate or document.location in JavaScript?

What's the preferred method to use to change the location of the current web page using JavaScript? I've seen both window.navigate and document.location used. Are there any differences in behavior? Are there differences in browser implementations?


Source: (StackOverflow)

Advertisements

How to Force Child Div to 100% of Parent's Div Without Specifying Parent's Height?

I would assume this is possible, but i just cant figure it out..

i have a site thats basic structure is set up as follows.

<div id="header"></div>

<div id="main">
  <div id="navigation"></div>
  <div id="content"></div>
</div>

<div id="footer"></div>

The navigation is a left hand navigation with a content div to the right of it. I would like to scale the navigation vertically to be the same height as the content div depending on what is loaded into the content div. the information for the content div is pulled in through PHP, so it is different every time. anyway long story short. Is there a way to set it so that my navigation will always be the full height of the content div no matter which page is loaded?


Source: (StackOverflow)

VIM Super Fast Navigation

The only thing that I miss about using other editors is finding my place with the mouse. I can look with my eyes to a specific area on the file and with a motion of the mouse and a click I am there. With VIM i have to jjjjjkkkkkkjjjjhhhh... almost there hhhhh oh crap I missed by 3 characters, lll.

I am learning to do marks and i found a bookmarks plugin that is great, I can create markers and destroy them with <f3> and navigate to them with unfortunately the marks are forgotten when the file is closed.

How do you all super navigate files? I know I could also do 5j7k4j5h and so forth, but there must be a plugin that can read my eyes and put the cursor where I really need it..

I also have learned to use /% to search for a specific term. It does help but all the matching characters are highlighted through out the document.


Source: (StackOverflow)

Reload UITableView when navigating back?

I have a top level UIViewController that contains a UITableView. The top level UIViewController instantiates a NavigationController, and pushes another UIViewController onto the NavigationController. I.E. we push into a new, second view. This second view has the usual "Back" button in the upper left hand corner to allow you to navigate back to the top level view.

Is it possible, when navigating back to the top level view from the second view, to redraw the UITableView in the top level view, using data generated in the second view, by calling cellForRowAtIndexPath in the top level and if so, how does one do this?


Source: (StackOverflow)

Vim file navigation

I'm trying really hard to learn vim after using TextMate for the last few years.

I've started to commit some of the in-file navigation to memory but I'm struggling with navigating between multiple files.

In my workflow it is pretty common that I'm flipping between a handful of files pretty regularly (enough files such that split-pane windows become too small).

I'm currently using NERDTree but find drilling down into directories cumbersome as well as constantly using CTRL+W h/CTRL+W l to hop back and forth.

I think I would do better with tabs I can easily toggle between but maybe I need to use a different workflow.

I'd also like a "Go to File..." shortcut like CMD+T in TextMate. I've found fuzzy_file_finder but it requires vim to be built with Ruby bindings which isn't the case the native installs I've worked on.

While I could rebuild the main reason I want to switch to vim is so I can have one editor environment that I know will easily work across any platform.

The options out there are overwhelming any ideas are much appreciated!


Source: (StackOverflow)

Programmatically scroll to an Anchor Tag

Consider the following code:

<a rel='nofollow' href="#label2">GoTo Label2</a>
... [content here] ...
<a name="label0"></a>More content
<a name="label1"></a>More content
<a name="label2"></a>More content
<a name="label3"></a>More content
<a name="label4"></a>More content

Is there a way to emulate clicking on the "GoTo Label2" link to scroll to the appropriate region on the page through code?

EDIT: An acceptable alternative would be to scroll to an element with a unique-id, which already exists on my page. I would be adding the anchor tags if this is a viable solution.


Source: (StackOverflow)

Can you help me center a

I've been puzzling over something which ought to be very easy indeed, but after a fruitless three hours I've not yet solved it:

A friend asked me to fix the template of his WordPress website so that the horizontal navigation menu-bar is centered horizontally on the page. He wants it to fit snugly across the bottom-middle of the red-section - then it would just fit between the two emblems on either side of the red page.

The red section (class="header") has text-align set to center. This seems to be good enough to ensure that the title and the description text underneath it are center aligned but for some reason I cannot make the menu (which is a ul) align to the center of the page.

Would anybody care to suggest what I'm doing wrong? Why is it that I cannot get the menu centered? What is it that I need to change in the style-sheet to get it working?


Source: (StackOverflow)

Android Navigation Drawer on top ActionBar

I'm trying to make the navigation drawer over the action bar when it was slide to the right like this app: [Removed]

This is my main activity's layout:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout ...>
    <RelativeLayout android:orientation="vertical" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent">
        ...
    </RelativeLayout>
    <fragment android:name="com...." 
        android:layout_gravity="start" 
        android:id="@id/navigation" 
        android:layout_width="@dimen/navigation_menu_width" 
        android:layout_height="fill_parent" />
</android.support.v4.widget.DrawerLayout>

Some other questions on stackoverflow are similar such as this question but all answers are recommend to use sliding menu lib. But this app they still use android.support.v4.widget.DrawerLayout and they succeed. Don't ask me how I know they use the standard navigation drawer but I sure about it.

Would be really appreciate for your helps.


HERE IS THE FINAL SOLUTION: many thanks to @Peter Cai THIS WORKS PERFECTLY. https://github.com/lemycanh/DrawerOnTopActionBar

Screen Capture Translucent on KitKat


Source: (StackOverflow)

Bootstrap 3 collapsed menu doesn't close on click

I have a more or less standard navigation from bootstrap 3

<body data-spy="scroll" data-target=".navbar-collapse">
    <!-- ---------- Navigation ---------- -->
    <div class="navbar navbar-fixed-top" role="navigation">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="sr-only">Toggle navigation</span>
                </button>
                <a class="navbar-brand" rel='nofollow' href="index.html"> <img src="#"></a>
            </div>
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav navbar-right">
                    <li class="active"><a rel='nofollow' href="#home">Home</a></li>
                    <li><a rel='nofollow' href="#one">One</a></li>
                    <li><a rel='nofollow' href="#two">Two</a></li>
                    <li><a rel='nofollow' href="#three">Three</a></li>
                    <li><a rel='nofollow' href="#four">Four</a></li>
                </ul>
            </div>
        </div>
    </div>

It collapses normally on smaller devices. Clicking on the menu button expands the menu but if I click (or touch for that matter) on a menu link, the menu stays open. What do I have to do, to close it again?

Edit, thanks to @VCNinc this worked for me:

$(document).ready(function () {
    $(".navbar-nav li a").click(function(event) {
        $(".navbar-collapse").collapse('hide');
    });
});

Source: (StackOverflow)

Detecting Back Button/Hash Change in URL

I just set up my new homepage at http://ritter.vg. I'm using jQuery, but very minimally.
It loads all the pages using AJAX - I have it set up to allow bookmarking by detecting the hash in the URL.

 //general functions
 function getUrl(u) {
      return u + '.html';
 }
 function loadURL(u)    {
      $.get(getUrl(u), function(r){
                $('#main').html(r);
           }
      );
 }
 //allows bookmarking
 var hash = new String(document.location).indexOf("#");
 if(hash > 0)
 {
      page = new String(document.location).substring(hash + 1);
      if(page.length > 1)
        loadURL(page);
      else
        loadURL('news');
 }
 else
      loadURL('news');

But I can't get the back and forward buttons to work.

Is there a way to detect when the back button has been pressed (or detect when the hash changes) without using a setInterval loop? When I tried those with .2 and 1 second timeouts, it pegged my CPU.


Source: (StackOverflow)

React-Native - Custom navigation with Navigator component

I'm exploring possibilities of React Native while developing a demo app with custom navigation between views with the help of Navigator component - http://facebook.github.io/react-native/docs/navigator.html#content

The main app class renders navigator and inside renderScene returns passed component:

class App extends React.Component {
    render() {
        return (
            <Navigator
                initialRoute={{name: 'WelcomeView', component: WelcomeView}}
                configureScene={() => {
                    return Navigator.SceneConfigs.FloatFromRight;
                }}
                renderScene={(route, navigator) => {
                    // count the number of func calls
                    console.log(route, navigator); 

                    if (route.component) {
                        return React.createElement(route.component, { navigator });
                    }
                }}
             />
        );
    }
}

For now app contains 2 views:

class FeedView extends React.Component {
    render() {
        return (
            <View style={styles.container}>
                <Text>
                    Feed View!
                </Text>
            </View>
        );
    }
}

class WelcomeView extends React.Component {
    onPressFeed() {
        this.props.navigator.push({
            name: 'FeedView',
            component: FeedView
        });
    }

    render() {
        return (
            <View style={styles.container}>
                <Text style={styles.welcome}>
                    Welcome View!
                </Text>

                <Text onPress={this.onPressFeed.bind(this)}>
                    Go to feed!
                </Text>
            </View>
        );
    }
}

What I want to figure out is -

  • I see in logs that when pressing "go to feed" renderScene is called several times though the view renders correctly once. Is it how the animation works?

    index.ios.js:57 Object {name: 'WelcomeView', component: function}
    index.ios.js:57 Object {name: 'FeedView', component: function}
    // renders Feed View
    
  • Generally does my approach conforms the React way, or it can be done better?

What I want to achieve is something similar to NavigatorIOS but without navigation bar (however some views will have their own custom navigation bar).


Source: (StackOverflow)

How to stretch html / css horizontal navigation items evenly and fully across a specified container

I'd like to stretch 6 nav items evenly across a 900px container, with an even amount of white space between. For instance...

---| 900px Container |---

---| HOME    ABOUT    BASIC SERVICES    SPECIALTY SERVICES    OUR STAFF    CONTACT US |---

Currently, the best method I can find to do this is the following:

nav ul {
  width: 900px; 
  margin: 0 auto;
}

nav li {
  line-height: 87px;
  float: left;
  text-align: center;
  width: 150px;
}

The PROBLEM with this is two fold. First of all, it doesn't truly justify it, but rather spreads the li tags evenly throughout the ul tag.. creating uneven white-space between smaller menu items like "HOME" or "ABOUT" and larger ones like "BASIC SERVICES".

The second problem is that the layout breaks if a nav item is larger than 150px, which SPECIALTY SERVICES is - even though there is more than enough space for the whole nav.

Can anyone solve this for me? I've been scouring the web for solutions, and they all seem to come up short. CSS / HTML only if possible...

Thanks!

UPDATE (7/29/13): Using table-cell is the best modern way to implement this layout. See felix's answer below. The table cell property works on 94% of browsers currently. You'll have to do something about IE7 and below, but otherwise should be ok.

UPDATE (7/30/13): Unfortunately, there is a webkit bug that impacts this if you're combining this layout with Media Queries. For now you'll have to avoid changing the 'display' property. See Webkit Bug.

UPDATE (7/25/14): There is a better solution to this below now involving text-align: justify. Using this is simpler and you'll avoid the Webkit bug.


Source: (StackOverflow)

Side navigation menu like Facebook app

I'm looking for something similar to what the new Facebook app has implemented for the Android/ios mobile applications. I am referring to a side navigation menu which opens with a finger movement. Something like this

Is there any library or example where I can check?

Thank you very much.


Source: (StackOverflow)

VIM Highlight the whole current line

What is the best way to highlight the whole current line in VIM? In some IDEs I am able to set some sort of 20% opacity of the line I am editing, this is great to find where I am rather quickly.


Source: (StackOverflow)