Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Modify View Layout from UITableView Edit

lukeirvinlukeirvin Posts: 388Registered Users @ @
I need some advice to get a better understanding of how to do this.

To break down what I want to do:

The Main View Controller of the app has a Table View. Let's say this table has four cells, A, B, C, and D.

The top group of cells, A, B, and C, will each push to detailed views to input information.

The bottom cell, D, will push to the Preview view controller to view this information on one single view.

If I edit the table, meaning rearrange the cells from A, B, C to B, A, C I want the order of content on the Preview View Controller to do the same thing.

Does each set of data need to be in it's own UIView, and then each UIView is a subview of the Preview View?

If anyone has a tutorial or example of how this should be done or can break it down for me I would greatly appreciate it!

Thanks!

Replies

  • GHuebnerGHuebner Posts: 665Registered Users @ @ @
    Not sure if you are using storyboards or not. So the answer would depend on that fact. But, I would create a two segues from your view (not the tableviewcell) to the new view controller. Then, in your did select row at index path method, evaluate the cells contents and determine which segue to perform. You will need to know what would trigger which segue based on the cells index and index to your data populating the cells.
  • lukeirvinlukeirvin Posts: 388Registered Users @ @
    Not using Storyboards
  • Duncan CDuncan C Posts: 9,112Tutorial Authors, Registered Users @ @ @ @ @ @ @
    lukeirvin said:

    I need some advice to get a better understanding of how to do this.

    To break down what I want to do:

    The Main View Controller of the app has a Table View. Let's say this table has four cells, A, B, C, and D.

    The top group of cells, A, B, and C, will each push to detailed views to input information.

    The bottom cell, D, will push to the Preview view controller to view this information on one single view.

    If I edit the table, meaning rearrange the cells from A, B, C to B, A, C I want the order of content on the Preview View Controller to do the same thing.

    Does each set of data need to be in it's own UIView, and then each UIView is a subview of the Preview View?

    If anyone has a tutorial or example of how this should be done or can break it down for me I would greatly appreciate it!

    Thanks!


    So you have a main view controller that will push detail view controllers based on the cell the user taps.

    You want the preview view controller to reflect the order of data the user has set in the main view controller.

    Make your data model a singleton object so you can read/write to it from any of your VCs. Use a mutable array to store the data.

    In your main view controller, if the user reorders the cells, re-order the data in the mutable array.

    In your preview view controller, simply load the data from the singleton and display it. Since you've changed the data, the preview view controller will display the updated data.
    Regards,
    Duncan C
    WareTo

    widehead.gif
    Animated GIF created with Face Dancer, available for free in the app store.

    I'm available for one-on-one help at CodeMentor
  • lukeirvinlukeirvin Posts: 388Registered Users @ @
    Not having much luck with this.

    I may need some help setting up my Singleton.

    Here's what I have so far:

    + (id)sharedInformation
    {
    @synchronized(self)
    {
    if (_sharedMyInformation == nil)
    {
    _sharedMyInformation = [[self alloc] init];
    _sharedMyInformation.informationArray = [[NSMutableArray alloc] init];
    _sharedMyInformation.nameString = [[NSString alloc] init];
    _sharedMyInformation.jobString = [[NSString alloc] init];
    [_sharedMyInformation.informationArray addObject:_sharedMyInformation.nameString];
    [_sharedMyInformation.informationArray addObject:_sharedMyInformation.jobString];
    }
    }
    return _sharedMyInformation;
    }
  • lukeirvinlukeirvin Posts: 388Registered Users @ @
    edited May 2013
    If I set the NSString's in the Singleton then I am able to accomplish what I want. I can rearrange the table and the Label's rearrange in the Preview.

    The issue I am having with now is updating the NSStrings from the detailed UIViewController's.

    Here's how I am saving the text:

    - (IBAction)saveButtonTapped
    {
    MyInformation * myInformation = [MyInformation sharedInformation];

    if (_nameTextField.text == nil)
    {
    myInformation.nameString = @"";
    }
    else
    {
    myInformation.nameString = _nameTextField.text;
    }

    [self.navigationController popToRootViewControllerAnimated:YES];
    }

    Is this accurate? Am I missing something?
Sign In or Register to comment.