nicklockwood / layout

A declarative UI framework for iOS
MIT License
2.23k stars 97 forks source link

`UINavigationController` usage #15

Closed eimantas closed 7 years ago

eimantas commented 7 years ago

How can I set a custom table view controller for the UINavigationController? Here's a thing that I have:

Main.xml

<UITabBarController>

    <UIViewController
        title="Table"
        tabBarItem.title="Table"
        xml="MyTableViewController.xml" />

    <UIViewController
    tabBarItem.title="Scroll"
        xml="ScrollViewController.xml" />
</UITabBarController>

MyTableViewController.xml

<UINavigationController>
    <MyTableViewController
        title="Table">
        <UITableView
            width="100%"
            height="100%"
            rowHeight="44"
            estimatedRowHeight="44"
            >
            <UITableViewCell
                reuseIdentifier="Cell"
                rowHeight="44">
                <UILabel top="8" left="8" text="{row}" />
            </UITableViewCell>
        </UITableView>
    </MyTableViewController>
</UINavigationController>

ScrollViewController

<UINavigationController>
    <ScrollViewController>
        <UIView
            backgroundColor="#faaa"
            width="100%"
            height="100%"
            >
            <UIScrollView
                width="parent.width"
                height="parent.height"
                >
            </UIScrollView>
        </UIView>
    </ScrollViewController>
</UINavigationController>

The bug that I think I found is that if root view controller for navigation controller inherits from view controller all works fine (I have print statement in ScrollViewController.viewDidLoad and it gets printed when the app starts, however the MyTableViewController print statement doesn't get executed and looking from view debugger, the root view controller for the first tab is UITableViewController, but the instance for the second tab is ScrollViewController as it should be.

I have added rowHeight attributes as the rows in the first tabe are only around 20pts high:

simulator screen shot - iphone 7 - 2017-08-10 at 14 48 47

nicklockwood commented 7 years ago

Fixed in 0.4.9