TabViewController to - NavigationViewController to - TableViewController

Hi. I am trying to make an applicaton that follows the following structure and I am trying to make sure I have it laid out right...
I have a tab bar controller as the project type... I have added new "tabs" as navigation controllers and view controllers so that when pressing on a tab you will see a static view (such as for settings) and for other tabs you will be able to navigate from screen to screen.
Most if not all of the screens will use a TableView. My program should flow something like..
Tab 1
--List of items
----List of properties of selected item (tool bar displays instead of tab bar)
------View of details of selected item properties (tool bar displays instead of tab bar)
Tab 2
--TBD (similar to tab 1)
Tab 3
--TBD (similar to tab 1)
Tab 4
--TBD (similar to tab 1)
Tab 5
--List of settings
and here is the structure I have laid out in IB
MainWindow...
Tab Bar controller
--Navigation Controller one
----View Controller (one)
--View Controller (five)
Each view is linked to a separate xib file with its own view.
Currently each seperate file is simply a view with text to test that it is working...
I would like to make most of them Table Views.
So my question is... how to I go from Tab Bar controller to a table view that will drill down to more views? Most views after the first level will be made programatically based on data pulled in.
Should each xib file contain a table view controller? should there be seperate navigation controllers for each tab button that points to the table view controllers? or do I not need a navigation controller at all and just have each item in the tab bar be a table view controller?
Thanks.

Someone please help me...
I need to create a tab bar that can drill down into seperate tables and ditch the tab bar on the second level..... I have looked the elements example but its all done programatically... I need to do at least some of it in IB....

Similar Messages

  • How can I implentate a search bar in TableViewController iOS

    How can I implentate a search bar in my TableViewController? Code:
    //  ViewController.m
    //  Movie List
    //  Created by Damian on 20/02/15.
    //  Copyright (c) 2015 Tika Software. All rights reserved.
    #import "ViewController.h"
    @interface ViewController ()
    These outlets to the buttons use a `strong` reference instead of `weak` because we want
    to keep the buttons around even if they're not inside a view.
    @property (nonatomic, strong) IBOutlet UIBarButtonItem *editButton;
    @property (nonatomic, strong) IBOutlet UIBarButtonItem *cancelButton;
    @property (nonatomic, strong) IBOutlet UIBarButtonItem *deleteButton;
    @property (nonatomic, strong) IBOutlet UIBarButtonItem *addButton;
    // A simple array of strings for the data model.
    @property (nonatomic, strong) NSMutableArray *dataArray;
    @end
    #pragma mark -
    @implementation ViewController
    - (void)viewDidLoad
        [super viewDidLoad];
         This option is also selected in the storyboard. Usually it is better to configure a table view in a xib/storyboard, but we're redundantly configuring this in code to demonstrate how to do that.
        self.tableView.allowsMultipleSelectionDuringEditing = YES;
        // populate the data array with some example objects
        self.dataArray = [NSMutableArray new];
        NSString *itemFormatString = NSLocalizedString(@"Movie %d", @"Format string for item");
        for (unsigned int itemNumber = 1; itemNumber <= 0; itemNumber++)
            NSString *itemName = [NSString stringWithFormat:itemFormatString, itemNumber];
            [self.dataArray addObject:itemName];
        // make our view consistent
        [self updateButtonsToMatchTableState];
    #pragma mark - UITableViewDelegate
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
        return self.dataArray.count;
    - (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
        // Update the delete button's title based on how many items are selected.
        [self updateDeleteButtonTitle];
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
        // Update the delete button's title based on how many items are selected.
        [self updateButtonsToMatchTableState];
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
        // Configure a cell to show the corresponding string from the array.
        static NSString *kCellID = @"cellID";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellID];
        cell.textLabel.text = [self.dataArray objectAtIndex:indexPath.row];
        return cell;
    #pragma mark - Action methods
    - (IBAction)editAction:(id)sender
        [self.tableView setEditing:YES animated:YES];
        [self updateButtonsToMatchTableState];
    - (IBAction)cancelAction:(id)sender
        [self.tableView setEditing:NO animated:YES];
        [self updateButtonsToMatchTableState];
    - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
        // The user tapped one of the OK/Cancel buttons.
        if (buttonIndex == 0)
            // Delete what the user selected.
            NSArray *selectedRows = [self.tableView indexPathsForSelectedRows];
            BOOL deleteSpecificRows = selectedRows.count > 0;
            if (deleteSpecificRows)
                // Build an NSIndexSet of all the objects to delete, so they can all be removed at once.
                NSMutableIndexSet *indicesOfItemsToDelete = [NSMutableIndexSet new];
                for (NSIndexPath *selectionIndex in selectedRows)
                    [indicesOfItemsToDelete addIndex:selectionIndex.row];
                // Delete the objects from our data model.
                [self.dataArray removeObjectsAtIndexes:indicesOfItemsToDelete];
                // Tell the tableView that we deleted the objects
                [self.tableView deleteRowsAtIndexPaths:selectedRows withRowAnimation:UITableViewRowAnimationAutomatic];
            else
                // Delete everything, delete the objects from our data model.
                [self.dataArray removeAllObjects];
                // Tell the tableView that we deleted the objects.
                // Because we are deleting all the rows, just reload the current table section
                [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationAutomatic];
            // Exit editing mode after the deletion.
            [self.tableView setEditing:NO animated:YES];
            [self updateButtonsToMatchTableState];
    - (IBAction)deleteAction:(id)sender
        // Open a dialog with just an OK button.
        NSString *actionTitle;
        if (([[self.tableView indexPathsForSelectedRows] count] == 1)) {
            actionTitle = NSLocalizedString(@"Are you sure you want to remove this movie?", @"");
        else
            actionTitle = NSLocalizedString(@"Are you sure you want to remove these movies?", @"");
        NSString *cancelTitle = NSLocalizedString(@"Cancel", @"Cancel title for item removal action");
        NSString *okTitle = NSLocalizedString(@"OK", @"OK title for item removal action");
        UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:actionTitle
                                                                 delegate:self
                                                        cancelButtonTitle:cancelTitle
                                                   destructiveButtonTitle:okTitle
                                                        otherButtonTitles:nil];
        actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
        // Show from our table view (pops up in the middle of the table).
        [actionSheet showInView:self.view];
    - (IBAction)addAction:(id)sender
        [self.dataArray addObject:@"New Movie"];
        // Tell the tableView about the item that was added.
        NSIndexPath *indexPathOfNewItem = [NSIndexPath indexPathForRowself.dataArray.count - 1) inSection:0];
        [self.tableView insertRowsAtIndexPaths:@[indexPathOfNewItem]
                              withRowAnimation:UITableViewRowAnimationAutomatic];
        // Tell the tableView we have finished adding or removing items.
        [self.tableView endUpdates];
        // Scroll the tableView so the new item is visible
        [self.tableView scrollToRowAtIndexPath:indexPathOfNewItem
                              atScrollPosition:UITableViewScrollPositionBottom
                                      animated:YES];
        // Update the buttons if we need to.
        [self updateButtonsToMatchTableState];
    #pragma mark - Updating button state
    - (void)updateButtonsToMatchTableState
        if (self.tableView.editing)
            // Show the option to cancel the edit.
            self.navigationItem.rightBarButtonItem = self.cancelButton;
            [self updateDeleteButtonTitle];
            // Show the delete button.
            self.navigationItem.leftBarButtonItem = self.deleteButton;
        else
            // Not in editing mode.
            self.navigationItem.leftBarButtonItem = self.addButton;
            // Show the edit button, but disable the edit button if there's nothing to edit.
            if (self.dataArray.count > 0)
                self.editButton.enabled = YES;
            else
                self.editButton.enabled = NO;
            self.navigationItem.rightBarButtonItem = self.editButton;
    - (void)updateDeleteButtonTitle
        // Update the delete button's title, based on how many items are selected
        NSArray *selectedRows = [self.tableView indexPathsForSelectedRows];
        BOOL allItemsAreSelected = selectedRows.count == self.dataArray.count;
        BOOL noItemsAreSelected = selectedRows.count == 0;
        if (allItemsAreSelected || noItemsAreSelected)
            self.deleteButton.title = NSLocalizedString(@"Delete All", @"");
        else
            NSString *titleFormatString =
            NSLocalizedString(@"Delete (%d)", @"Title for delete button with placeholder for number");
            self.deleteButton.title = [NSString stringWithFormat:titleFormatString, selectedRows.count];
    @end

    Make sure that you do not run Firefox in full screen mode (press F11 or Fn + F11 to toggle; Mac: Command+Shift+F).
    *https://support.mozilla.org/kb/how-to-use-full-screen
    Make sure that toolbars like the "Navigation Toolbar" and the "Bookmarks Toolbar" are visible.
    *Firefox menu button > Options
    *View > Toolbars (press F10 to display the menu bar)
    *Right-click empty toolbar area
    Use Toolbar Layout (Customize) to open the Customize window and set which toolbar items to display.
    *check that "Bookmarks Toolbar items" is on the Bookmarks Toolbar
    *if "Bookmarks Toolbar items" is not on the Bookmarks Toolbar then drag it back from the toolbar palette into the Customize window to the Bookmarks Toolbar
    *if missing items are in the toolbar palette then drag them back from the Customize window on the toolbar
    *if you do not see an item on a toolbar and in the toolbar palette then click the "Restore Default Set" button to restore the default toolbar setup
    *https://support.mozilla.org/kb/How+to+customize+the+toolbar
    *https://support.mozilla.org/kb/Back+and+forward+or+other+toolbar+items+are+missing

  • How can I change the name of item in TableViewController iOS

    How can I change the name of item in TableViewController? I want to be able to change the title of an item if I added one. Code:
    //  ViewController.m
    //  Movie List
    //  Created by Damian on 20/02/15.
    //  Copyright (c) 2015 Tika Software. All rights reserved.
    #import "ViewController.h"
    @interface ViewController ()
    These outlets to the buttons use a `strong` reference instead of `weak` because we want
    to keep the buttons around even if they're not inside a view.
    @property (nonatomic, strong) IBOutlet UIBarButtonItem *editButton;
    @property (nonatomic, strong) IBOutlet UIBarButtonItem *cancelButton;
    @property (nonatomic, strong) IBOutlet UIBarButtonItem *deleteButton;
    @property (nonatomic, strong) IBOutlet UIBarButtonItem *addButton;
    // A simple array of strings for the data model.
    @property (nonatomic, strong) NSMutableArray *dataArray;
    @end
    #pragma mark -
    @implementation ViewController
    - (void)viewDidLoad
        [super viewDidLoad];
         This option is also selected in the storyboard. Usually it is better to configure a table view in a xib/storyboard, but we're redundantly configuring this in code to demonstrate how to do that.
        self.tableView.allowsMultipleSelectionDuringEditing = YES;
        // populate the data array with some example objects
        self.dataArray = [NSMutableArray new];
        NSString *itemFormatString = NSLocalizedString(@"Movie %d", @"Format string for item");
        for (unsigned int itemNumber = 1; itemNumber <= 0; itemNumber++)
            NSString *itemName = [NSString stringWithFormat:itemFormatString, itemNumber];
            [self.dataArray addObject:itemName];
        // make our view consistent
        [self updateButtonsToMatchTableState];
    #pragma mark - UITableViewDelegate
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
        return self.dataArray.count;
    - (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
        // Update the delete button's title based on how many items are selected.
        [self updateDeleteButtonTitle];
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
        // Update the delete button's title based on how many items are selected.
        [self updateButtonsToMatchTableState];
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
        // Configure a cell to show the corresponding string from the array.
        static NSString *kCellID = @"cellID";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellID];
        cell.textLabel.text = [self.dataArray objectAtIndex:indexPath.row];
        return cell;
    #pragma mark - Action methods
    - (IBAction)editAction:(id)sender
        [self.tableView setEditing:YES animated:YES];
        [self updateButtonsToMatchTableState];
    - (IBAction)cancelAction:(id)sender
        [self.tableView setEditing:NO animated:YES];
        [self updateButtonsToMatchTableState];
    - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
        // The user tapped one of the OK/Cancel buttons.
        if (buttonIndex == 0)
            // Delete what the user selected.
            NSArray *selectedRows = [self.tableView indexPathsForSelectedRows];
            BOOL deleteSpecificRows = selectedRows.count > 0;
            if (deleteSpecificRows)
                // Build an NSIndexSet of all the objects to delete, so they can all be removed at once.
                NSMutableIndexSet *indicesOfItemsToDelete = [NSMutableIndexSet new];
                for (NSIndexPath *selectionIndex in selectedRows)
                    [indicesOfItemsToDelete addIndex:selectionIndex.row];
                // Delete the objects from our data model.
                [self.dataArray removeObjectsAtIndexes:indicesOfItemsToDelete];
                // Tell the tableView that we deleted the objects
                [self.tableView deleteRowsAtIndexPaths:selectedRows withRowAnimation:UITableViewRowAnimationAutomatic];
            else
                // Delete everything, delete the objects from our data model.
                [self.dataArray removeAllObjects];
                // Tell the tableView that we deleted the objects.
                // Because we are deleting all the rows, just reload the current table section
                [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationAutomatic];
            // Exit editing mode after the deletion.
            [self.tableView setEditing:NO animated:YES];
            [self updateButtonsToMatchTableState];
    - (IBAction)deleteAction:(id)sender
        // Open a dialog with just an OK button.
        NSString *actionTitle;
        if (([[self.tableView indexPathsForSelectedRows] count] == 1)) {
            actionTitle = NSLocalizedString(@"Are you sure you want to remove this movie?", @"");
        else
            actionTitle = NSLocalizedString(@"Are you sure you want to remove these movies?", @"");
        NSString *cancelTitle = NSLocalizedString(@"Cancel", @"Cancel title for item removal action");
        NSString *okTitle = NSLocalizedString(@"OK", @"OK title for item removal action");
        UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:actionTitle
                                                                 delegate:self
                                                        cancelButtonTitle:cancelTitle
                                                   destructiveButtonTitle:okTitle
                                                        otherButtonTitles:nil];
        actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
        // Show from our table view (pops up in the middle of the table).
        [actionSheet showInView:self.view];
    - (IBAction)addAction:(id)sender
        [self.dataArray addObject:@"New Movie"];
        // Tell the tableView about the item that was added.
        NSIndexPath *indexPathOfNewItem = [NSIndexPath indexPathForRowself.dataArray.count - 1) inSection:0];
        [self.tableView insertRowsAtIndexPaths:@[indexPathOfNewItem]
                              withRowAnimation:UITableViewRowAnimationAutomatic];
        // Tell the tableView we have finished adding or removing items.
        [self.tableView endUpdates];
        // Scroll the tableView so the new item is visible
        [self.tableView scrollToRowAtIndexPath:indexPathOfNewItem
                              atScrollPosition:UITableViewScrollPositionBottom
                                      animated:YES];
        // Update the buttons if we need to.
        [self updateButtonsToMatchTableState];
    #pragma mark - Updating button state
    - (void)updateButtonsToMatchTableState
        if (self.tableView.editing)
            // Show the option to cancel the edit.
            self.navigationItem.rightBarButtonItem = self.cancelButton;
            [self updateDeleteButtonTitle];
            // Show the delete button.
            self.navigationItem.leftBarButtonItem = self.deleteButton;
        else
            // Not in editing mode.
            self.navigationItem.leftBarButtonItem = self.addButton;
            // Show the edit button, but disable the edit button if there's nothing to edit.
            if (self.dataArray.count > 0)
                self.editButton.enabled = YES;
            else
                self.editButton.enabled = NO;
            self.navigationItem.rightBarButtonItem = self.editButton;
    - (void)updateDeleteButtonTitle
        // Update the delete button's title, based on how many items are selected
        NSArray *selectedRows = [self.tableView indexPathsForSelectedRows];
        BOOL allItemsAreSelected = selectedRows.count == self.dataArray.count;
        BOOL noItemsAreSelected = selectedRows.count == 0;
        if (allItemsAreSelected || noItemsAreSelected)
            self.deleteButton.title = NSLocalizedString(@"Delete All", @"");
        else
            NSString *titleFormatString =
            NSLocalizedString(@"Delete (%d)", @"Title for delete button with placeholder for number");
            self.deleteButton.title = [NSString stringWithFormat:titleFormatString, selectedRows.count];
    @end

    Hey JB001,
    Sounds like you have more going on than just a simple issue with Home Sharing and more dealing with Wi-Fi syncing. Start with the article below and see if that may resolve it.
    iTunes 10.5 and later: Troubleshooting iTunes Wi-Fi syncing
    http://support.apple.com/kb/TS4062
    If it does not work out, then may I suggest contacting Apple for further assistance to walk you through it or just take that time that you were talking about to sort it out.
    Contact Apple Support
    https://getsupport.apple.com/GetproductgroupList.action
    Regards,
    -Norm G.

  • IB - TableViewController howto

    Hi everybody,
    please pardon my ignorance but I somehow cannot manage the logics behind TableViewController. I started a fresh new Tab Bar application and want to display table using the provided TableViewController. How should I connect them? It looks like I'm missing the last step only...

    gonna rephrase this question

  • TableViewController in a separate XIB

    Hello ppl,
    I am putting down an interface using IB and I'm having a few issues separating the interface into several xib files. I will explain what I need to do in detail.
    MainWindow.xib - main xib file, where I have a viewController defined. This view controller has two buttons, and an empty area where a table view needs to be displayed.
    TableView.xib - this xib has a tableviewController defined, which includes the table that needs to be displayed in the empty area of the viewController.
    What I need done is to put down the connections and settings in IB so that when the viewController loads, it automatically loads the TableView.xib and its corresponding TableViewController.
    The problem is, I cannot add a tableViewController inside my viewController and set its properties. Any ideas and how to do this?
    Thanks

    gonna rephrase this question

  • Index of tabViewController

    I need to link an IBAction(ie: tabChanged) to my tabViewController (appDelegate).
    -(IBAction)tabChanged:(id)sender{
    //change something in the current view.
    When I create the IBAction in both the m and h file everything is good. I can see it in interface builder. But there is nothing to link the action to on the tabBar or tabBarItems or tabBarController.
    I am not understanding where I am going wrong here.
    Can you link IBAction to the tab bar?

    I solved this problem by attaching the method i was calling to the viewWillAppear.

  • TableViewController in a separate xib file

    Hi guys,
    I am having some trouble with IB and connections and would greatly appreciate any help in this matter. I will explain what I am trying to do in detail.
    - In my MainWindow.xib, I have a viewController that presents several UI elements, and has an area reserved for a table view.
    - In a separate TableView.xib, I have a table view controller that defines and operates on the table that should be displayed within the viewController mentioned previously.
    I need to associate the designated region in my UI inside viewController with the tableViewControllers table inside the other xib file. I need detailed steps of to do in my initial view, and what objects to set appropriately to achieve this result.
    Thanks again for any help you can provide.
    James

    gonna rephrase this question

  • How to add toolbar to TableViewController with IB?

    I am trying to figure out Interface Builder, and want to add a toolbar to be displayed in a navigation-based project. This is what I did, but what am I missing?
    1) I added IBOutlet UIToolbar *toolbar; to RootViewController.h with properties and systhesize.
    2) I added a toolbar to the RootViewController IB document.
    3) In IB I connected toolbar IBOutlet object to Toolbar in Outlets.
    4) I can't figure how to alloc and init object. I have tried a few things but nothing shows up. Any help would be appreciated.
    Thanks,
    Bri

    Ok I see that if I add the toolbar view as a subview of the table view, I can't see the toolbar. I can get it to show up if I add it to the main window, but then the navigation controller cannot push and pop entire view, and I will have to figure out when navigation controller pushes and pops and will have to add and remove subview manually. There has to be a better way?
    I thought I got it to work, by adding a [self.view addSubview:toolbar], but it adds it to the actual table view, so it moves with the cells. How can I make it like the Navigation Bar?
    Note I read the View Controller Guide and Table View Guide, but it does not mention toolbars or subviews.
    Brian

  • Memory usage and memory warnings

    I have a problem with memory
    1) Short app decsription:
    TabbarController
    \ - 1.1 TAB: NavigationController
    _\1.1.1 - TableViewController(Groups)
    __\1.1.2 - TableViewController(Users)
    \ - 2 TAB: NavigationController
    _\2.1 - TableViewController(Statistic)
    __\2.2 - ViewController
    2) Problem:
    After some time of the application work ViewControllers receive "MemoryWarnings", after TableViewControllers (1.1.1) & (1.1.2) become empty. But ViewControllers dont receive "viewDidUnload" or "setView:nil" messages?
    What's wrong?
    How to display the tables content?

    I have a problem with memory
    1) Short app decsription:
    TabbarController
    \ - 1.1 TAB: NavigationController
    _\1.1.1 - TableViewController(Groups)
    __\1.1.2 - TableViewController(Users)
    \ - 2 TAB: NavigationController
    _\2.1 - TableViewController(Statistic)
    __\2.2 - ViewController
    2) Problem:
    After some time of the application work ViewControllers receive "MemoryWarnings", after TableViewControllers (1.1.1) & (1.1.2) become empty. But ViewControllers dont receive "viewDidUnload" or "setView:nil" messages?
    What's wrong?
    How to display the tables content?

  • How to find origin of scrolled UITableView

    Hi, I'm using self.view.frame within my tableViewController to get the origin of its UITableView
    If I scroll the table up (i.e. second row is now shown on top of the screen), self.view.frame continues to return an origin of {0,0} instead of {0, -80} even though the table has been scrolled up by 80 pixels (i.e. the height of the first table row)
    Does anyone know how to find out the amount (e.g. 80 pixels or 90 pixels etc..) by which a table is currently scrolled up by the user ?

    Dankeschön, that was the solution.
    I had also figured it out independently and just got here to update the post when I saw your reply. Thanks

  • Tab Bar Control and the Default "More" Behavior

    I've got a client who wants an app with 8 tabs. The only problem is that they don't like the default "more" behavior with the tableviewcontroller containing the extra tab content. What they want is to hit "more" to see the next four tabs replace the first four and then to toggle back if it's hit again.
    There are a few ways to do this, I guess. I could build a second viewcontroller/tabcontroller that comes on or leaves when "more" is touched. Is there a surer way of doing this? I'm sure I'm missing something basic, but I've googled my brains out on this one and just can't see it.

    You could use one TabbarController with 8 ViewControllers, and rotate them when the More tab is tapped:
    - (BOOL)tabBarController:(UITabBarController *)tbc shouldSelectViewController:(UIViewController *)vc {
    if (vc == tbc.moreNavigationController) {
    NSMutableArray *newVCs = [[NSMutableArray arrayWithCapacity:8] retain];
    for (int i = 0; i < 8; i++) {
    [newVCs addObject:[tbc.viewControllers objectAtIndex:(i + 4) % 8]];
    tbc.viewControllers = newVCs;
    [newVCs release];
    return NO;
    } else {
    return YES;

  • Why does a UITableView cell.contentView.bounds.size.width change with cell reuse?

    I use `cell.contentView.bounds.size.width` to calculate the position of a text field in a UITableView cell. When the cell is created, debug code reports the width as 302. When the cell scrolls off the screen and then back on, the debug code reports that the it is 280--every time. It doesn't seem to want to go back to 302 and stays stuck at 280. The net result is that the text field gets put in the wrong place the second time the field is put into the cell's contentView, though it was put in the right place the first time.
    I figure 22 is significant somehow, but I don't know what it is. Guessing it might be the disclosure arrow, I moved the "clear the cell" code up front of the width determination, including setting the accessory to nada.
    Can anybody tell me what's going on here?
    The code (with irrelevant--that I know of--stuff snipped out) looks like this:
    <code>
        // Customize the appearance of table view cells.
        - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
            static NSString *CellIdentifier = @"Cell";
                  NSUInteger section = [indexPath section];
                  NSUInteger row = [indexPath row];
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
            if (cell == nil) {
                cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
            // Configure the cell.
            while( [cell.contentView.subviews count] ){
                id subview = [cell.contentView.subviews objectAtIndex:0];
                [subview removeFromSuperview];
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        8< snip!
                  CGFloat          theCellWidth = cell.contentView.bounds.size.width - 44.0;
                  CGFloat theLineHeight = [[UIFont boldSystemFontOfSize: [UIFont labelFontSize]+1.0] lineHeight];
            NSLog(@"cell.contentView.bounds.size.width %1.0f",cell.contentView.bounds.size.width);
            if (0==section) {
                            switch (row) {
                                      case 2:
                        while( [cell.contentView.subviews count] ){
                            id subview = [cell.contentView.subviews objectAtIndex:0];
                            [subview removeFromSuperview];
                        cell.selectionStyle = UITableViewCellSelectionStyleNone;
                                                cell.textLabel.text = @" ";
                                                cell.detailTextLabel.text = @"The Age";
                                                theAgeTextField.frame = CGRectMake(10.0, 2.0, theCellWidth, theLineHeight);
        //                NSLog(@"cell.contentView %@",cell.contentView);
                                                theAgeTextField.text = theAge;
                                                theAgeTextField.font = [UIFont boldSystemFontOfSize: [UIFont labelFontSize]+1.0];
                                                theAgeTextField.keyboardType = UIKeyboardTypeDecimalPad;
                                                theAgeTextField.borderStyle = UITextBorderStyleNone;
                                                theAgeTextField.userInteractionEnabled = NO;
                                                [cell.contentView addSubview:theAgeTextField];
                                                cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
                                                break;
        8< snip! (lots of closing braces and other stuff omitted)
            return cell;
    <hr>
    </code>
    **Want to try this one at home, boys and girls?**
    Start with a new Navigation-based Application. Put the following code into RootViewController.m:
    <code>
        - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
            return 5;
        // Customize the appearance of table view cells.
        - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
            static NSString *CellIdentifier = @"Cell";
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
            if (cell == nil) {
                cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
            NSLog(@"cell.contentView.bounds.size.width %1.0f",cell.contentView.bounds.size.width);
            // Configure the cell.
            return cell;
    </code>
    There are only two changes in the default code required to make this happen: changing the number of rows in the section ("return 5") and the style of the cell must be _UITableViewCellStyleSubtitle_. Then, when you run the program, you'll see five lines of this:
    <code>
        2011-06-18 11:10:19.976 TestTableCells[7569:207] cell.contentView.bounds.size.width 302
        2011-06-18 11:10:19.978 TestTableCells[7569:207] cell.contentView.bounds.size.width 302
        2011-06-18 11:10:19.979 TestTableCells[7569:207] cell.contentView.bounds.size.width 302
        2011-06-18 11:10:19.980 TestTableCells[7569:207] cell.contentView.bounds.size.width 302
        2011-06-18 11:10:19.982 TestTableCells[7569:207] cell.contentView.bounds.size.width 302
    </code>
    Drag some cells off the screen (drag up--down doesn't do anything) and when they reappear, you get this:
    <code>
        2011-06-18 11:10:24.013 TestTableCells[7569:207] cell.contentView.bounds.size.width 320
        2011-06-18 11:10:24.047 TestTableCells[7569:207] cell.contentView.bounds.size.width 320
        2011-06-18 11:10:24.130 TestTableCells[7569:207] cell.contentView.bounds.size.width 320
    </code>
    Frankly, I'm frustrated as heck with this, and am so very tempted to pony up the $99 (without a working app, even) so I can have somebody at Apple weigh in on this one.
    <hr>
    Wanna' see something more interesting? Try this in place of the `static NSString...` line:
    <code>
            NSString *CellIdentifier = [NSString stringWithFormat: @"%d", arc4random() ];
            NSLog(@"%@",CellIdentifier);
    </code>
    Now, every time, the width in the log is _always_ 302. It would seem, then, that a reused cell has different content width than the original cell.
    Anybody got a clue on this?

    Hi,
    i guess the reason is that a newly create cell is create with a default frame by initWithStyle:
    But it's not yet added to any superview so you're logging that default size.
    After returning the new cell the tableViewController adds that cell as subview to the tableView which can lead to a resize of that cell.
    If the cell is scrolled off screen it's just removed from superview but stays the same size. If it's reused later it's still having the same size it had when removed from superview.
    Dirk
    initWithStyle:
    But it's not

  • How to determine what goes in the xib list

    How do you know when you need to add a View Controller or a Nav Item, or other classes in the same window that has File Owner and First Responder icons in it.
    I mean I understand I have a View showing and I link it to the File Owner, because the File Owner is the ViewController for that xib. But in what scenarios do you have to add another ViewController, or a TableViewController, of a NavController, or a NavItem or NavBar.
    And I do not mean the MainWindow.xib which has a Window, I mean other new xib files that you create to make the rest of your application.
    Thanks for the help
    Mark

    A general rule of thumb is that you will have a nib for each ViewController. Sometimes a VC is so simple that there is no need to lay it out interactively - these may be implemented entirely in code. In contrast a view may become so complex that you choose to implement some of its subviews in separate nibs.

  • How to use removeFromSuperView and dismissModelViewController same time ?

    I have a UIViewController *view1. By using
    [self presentModalViewController:view2 animated:YES];
    I added UIViewController *view2 to view1.
    I have a UITableViewController *table1;
    I added table1 to view2 by using
    [self.view addSubview:navController.view];
    Now I want to return back to the view1. I used removeFromSuperView, dismissModelViewController but I could not go to first view ?
    How should we use them ?
    Thank you.
    Message was edited by: srikanthrongali

    It shouldn't be necessary to use removeFromSuperview unless you wish to display view2 again, before returning to view1. To return to view1, dismissModelViewController must be sent to viewController1. The address of viewController1 will be found in viewController2.parentViewController. Thus, to return to view1 from the table view, it might be easiest to store the address of viewController2 in the table view controller.
    For example, add an instance variable called 'previousViewController' to your custom table view controller @interface. Assuming the table view controller is created by viewController2, pass the address like this:
    // ViewController2.m
    MyTableViewController *tableViewController = [[MyTableViewController alloc] init];
    tableViewController.previousViewController = self; // <-- save my address
    UINavigationController *navController = [[UINavigationController alloc]
    initWithRootViewController:tableViewController];
    Assuming you don't want view2 to appear again, return directly to view1 from the table view like this:
    // MyTableViewController.m
    [self.previousViewController.parentViewController dismissModelViewController];
    If you've navigated to other view controllers from the root table view controller, that controller's address will be found at position zero in the nav controller's stack.
    Btw, instead of adding the nav controller's view directly to view2, I would recommend presenting the nav controller as a modal controller from viewController2. You can "stack" as many modal view controllers as you want this way. You could then "pop" all the modal view controller's and return to view1 by sending dismissModelViewController to viewController1.
    Hope that helps!
    - Ray

  • Navigation does not work correctly

    I am implementing a table view with navigation. When the first row is selected, it should navigate to a second view with a "back" button in the navigation bar. In my case, when the cell or row is selected in the table, it does not do anything (does not give any error nor shows up a second view). I am sure that the table cell is selected correctly as I have tried outputting the row name using NSlog and it works. What could I be doing wrong with the navigation?
    childController = [[OneView alloc] initWithNibName:@"OneView"bundle:nil];
    childController.title = @" View Two";
    TableViewController *groupsController = [[[TableViewController alloc] initWithNibName:nil bundle:nil] autorelease];
    navController =[[UINavigationController alloc] initWithRootViewController:groupsController];
    [self.navController pushViewController:childController animated:YES];
    [childController autorelease];
    Thanks in advance,
    impacman

    No, unfortunatly we don't have an Edge connection and there are 100 plus pages with up to 6 images per page to scroll through, so taking screen shots is not really an option.

Maybe you are looking for