TableViewCell disappears when push UINavigationController in UITabBarController's More tableview - ios

I add 6 navigation controllers to UITabBarController's viewControllers. As normal, a More tab is created to list the last two. The problem is: after I select a table cell in the More table view, that cell's content fade out and disappear before the view controller push in. And then, after I back to the More table view by click the Back button, that cell's content show again. I guess the reason is More table view in its own navigation controller, and it push another navigation controller (created by me). I don't want to remove my navigation controller because I want to allow user rearrange tabs using the UITabBarController's Edit function. Can anyone suggest what I should do?

Create instances of your 6 navigation controllers in AppDelegate and retain them. And release in dealloc method

Just had the same problem. In my case I accidentally assigned the tabBarItem to the VC inside the navigation controller. When I instead initialized the tabBarItem on the navigation controller, the flickering / disappearing stopped.
MyViewController* viewController = [[MyViewController alloc] init];
UINavigationController* navigation = [[UINavigationController alloc] initWithRootViewController:viewController];
[viewController release];
// this has to be navigation.tabBarItem (not viewController.tabBarItem)
[navigation.tabBarItem initWithTitle:#"Title" image:[UIImage imageNamed:#"fancy.png"]
tag:42];
Initializing the tabBarItem on the viewController still showed the icon which made it harder to discover. I'm also not very sure (actually I think it's bad) about the way I initialize the tabBarItem (without alloc). But I had troubles with disappearing icons etc and hey, it works ;-)

Related

UITableViewcontroller in UINavigationController ios

I have a UITableViewcontroller as a rootviewcontroller for a UINavigationController. the UITableViewcontroller comes with a default edit button on the navigation bar. i am trying to replace this edit button with the default back button that usually shows up in a navigation controller. How can I get the default back button in the tableviewcontroller?
The back button shows up once you pushed another UIViewController onto the UINavigationController's view controller stack! It's automatically added by UINavigationController and the title that it displays will be the title property of the former UIViewController.
i understood my mistake. i noticed that the navigation controller of the rootviewcontroller was null.
below code helped in eliminating this error.
UINavigationController *navCMsgs = [[UINavigationController alloc] initWithRootViewController:ntvc];
[navCMsgs setViewControllers:[NSArray arrayWithObject:self]]
however, i have to explicity unhide the navigation bar as the setting for my rootviewcontroller is hidden

iOS how to go from xib file to a view controller in tab bar

i have a tab bar application
i am using storyboards and also navigation bar in my app
in my app
FirstViewController (in tab bar) with a button go to the SingleViewController (xib file and not on tab bar)
in SingleViewController there is a button too. and i want to go to one of the controllers which is on tab bar
in singleviewController's button method i have this code:
AylikGirisViewController *controller = [[AylikGirisViewController alloc] init];
[self.navigationController pushViewController:controller animated:YES];
it goes to the controller but i see a black screen and empty screen also moving to the AylikGirisViewController gets hard (i mean very slowly)
so i think my way is wrong
any ideas for the right way?
if you are using storyboard, you can simply drag another view controller onto the storyboard and give name as SingleViewController, you can easily push the SingleViewController onto the FirstViewController if you embed the FirstViewController in UINavigationController. Use storyboard segue to push the controller. Then you can call UITabBarController Delegate method to show the different viewController.

UISplitview with UITabBar behavior

I have moved from UITabBar to split view on my iPad application.
The view controllers are sent by the master to the detail which puts them into a UINavigationController.
// Detail manager called when a cell is selected on the master
UINavigationController *detailNavigationController = [[UINavigationController alloc] initWithRootViewController:_detailViewController];
UIViewController *mainNavigationViewController = [self.splitViewController.viewControllers objectAtIndex:0];
NSArray *viewControllers = [[NSArray alloc] initWithObjects:mainNavigationViewController, detailNavigationController, nil];
self.splitViewController.viewControllers = viewControllers;
Now every time a cell on the master is selected, the navigation controller on the detail view starts from the root.
Instead I would like to have the same behavior of the tab bar controller: when you move from one tab to another, the navigation stack for each tab is maintained. And when you select two times the same tab, the navigation stack pops to the root view controller.
How to implement this in a proper way with a split view based application?
You should make a navigation controller for each cell in the master table. When tapping a cell, you switch it accordingly. If the selected cell is tapped, you call popToRootViewController:animated: on the visible navigation controller. Of course, you have to subclass UISplitViewController to keep a reference to your navigation controllers. You would also have to create a MaterTableDelegate to tell you split VC, he should change the navcon in the detail side.
Starting from the suggestions of Levi I implemented a working solution.
To summarize:
Subclass UISplitViewController
Create on it a public reference to each UINavigationController you need
Inside the init of your UISplitViewController subclass initialize all the navigation controllers with their respective root UIViewControllers
According to your master-detail implementation, make sure that every time you select a cell in the master view, the right navigation controller (among all the one you have declared on your UISplitviewcontroller subclass) is presented on the detail view. I managed this with an NSinteger property on the detail manager (set on master cell selection) to tell it which navigation controller to present on the detail view.
If the same master view cell is selected twice, pop the corresponding navigation controller to root to simulate the same UITabBar behavior.
Hope this will help someone.

How to add a subview to a UINavigation Controller without losing navigation bar?

I have a SplitViewController which has two UITableViewControllers - one master/root one detail. Everything works swimmingly.
I have a UIView which is shown on the detail view controller before the user selects an item in the root view controller. It's set up like this:
[self.navigationController.view addSubview:makeSentenceHelperView];
[self.navigationController.view bringSubviewToFront:makeSentenceHelperView];
The detailViewController is set up like so:
UINavigationController *detailNav = [[[UINavigationController alloc] initWithRootViewController:detailViewController] autorelease];
Where detailViewController is a subclass of UITableView.
The problem is that this subView hides the buttons and navigation bar from the detail view controller's navigation bar - which is a problem when you launch the SVC in portrait mode (there's no way to select a root item with the root popup).
How can I present the view inside the navigation controller, so that the navigation bar and buttons appear in the detail view?
Don't make detailViewController a subclass of UIView, instead go with UIViewController. So your splitView array will contain a instance of UINavigationController(rootVC) and other of UIViewController (detailVC).
Add a toolbar on the top of detailViewController and in landscape mode left side will be covered by your UITableView of rootVC and you will be able to see toolbar where you can add some button to its right side (will probably serve as navigation bar..:) . Rest of the things can be handled by UISplitViewControllerDelegate.
To fix this I added a UINavigationController to my helper UIView, and added a UIButtonBarItem to call the popover for selecting a new item in the master view. It seems really simple in retrospect. The only tricky bit will be making the UIButtonBarItem hide when in landscape.

iPad: Merge concept of SplitViewController and NavigationController in RootView?

I'm having trouble merging the two concepts of using a SplitViewController in my main view and having the "RootView" controller that controls the left panes popup/sidebar table view.
I want to have the left "RootView" act as a navigation menu, but how do I do this when the RootView is tied through MainWindow.xib into the left pane of the SplitView?
Basically, I want the left navigation to work just like the built-in email applications folder drilldown navigation. Is there an example iPad project out there that uses both SplitView and a NavigationView for the left/Root pane?
After you create a SplitView project, open up the RootViewController.m file and look at the -tableViewDidSelectRowAtIndexPath method. You'll see that the item that you clicked is then set as a property of the DetailViewController.
The design you're looking for would require that you push another view controller onto the navigation stack. So if you imagine the e-mail application, when a user picks a folder, the detailView is not updated, but the next level of the Inbox is pushed onto the stack. When a user selects a message from the inbox, the detail view is updated with the message contents, and the RootViewController just stays where it's at.
in the -tableViewDidSelectRowAtIndexPath method, declare your new view controller
NextViewController *nextView = [[NextViewController alloc] initWithStyle:UITableViewStylePlain];
//This assumes you have another table view controller called NextViewController
//We assign it to the instance variable "nextView"
[self.navigationController pushViewController:nextView animated:YES];
//tells the navigation controller to "slide" the "nextView" instance on top
//if animated:NO it wouldn't slide, it would just "update"
[nextView release];
//release the viewController, it's now retained automatically by the NavigationController
Does this make sense?

Resources