1

The kind of design that I'm trying to accomplish in my app currently consists of a navigation controller that is the root controller for another View controller known as Test. Test consists of a UITableView in the top half and an UIImageView in the bottom half. THe navigation bar on the top (which is there as a result of the navigation controller) contains two buttons. The image at the link below ( I don't have the reputation points to post an image directly) should make it very clear.

https://i.stack.imgur.com/Htbe7.png

I want my design to be in such a way that depending on which button is pressed the image in the imageview is changed while, though the the text in the table view remains the same, they will transition to completely different screens going forward. To give an example, regardless of which button is tapped my table view will consist of : Option 1, Option 2 and Option 3. However, Option 1 for button A is different from Option B and so on.And, this is where the challenge is for me. I have been able to swap out the images based on the pressing of the button succefully. I did this by using an IBActionNavBarButonPressed and then swapping out the images based on the sender tag. Unfortunately, I don't know how to proceed from here. So for example I have my next couple of screens here. But, how do I set up the segues/transitions in such a way that only Option 1 of choice A goes to a certain screen and so on. From my understanding, I'm looking at a combination of prepareforSegue and the navBarbuttonPress IBAction but I'm still not sure how this would work.

Guys, I'm fairly certain as to what I'm trying to but since I'm new to objective C, I'm not completely sure of how to do it. Essentially, I want the logic to be something like, if(element.selected==0) && (IBActionProvider==1) { performSegueWithIdentifier:@"blah" sender.self]; My issue is whether to put this in the IBAction navBarButtonPressedMethod or to put it in the didSelectRowAtIndexPath method.

Thanks and sorry for the long question!

1 Answer 1

0

First you give names to other storyboards views. It contains left hand panel(Storyboard Identifier :).

You should create segue for all buttons and give identifier to it.

Then you should use prepareforSegue like this

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"ToContacts"])
    {    
        // Get reference to the destination view controller
        ContactVC *targetVC = [segue destinationViewController];
        // Pass any objects to the view controller here, like...
        targetVC.CompanyNme = selectedRowValue;
    }
    if ([[segue identifier] isEqualToString:@"ViewCompany"])
    {
        ContactVC *targetVC = [segue destinationViewController];
        targetVC.CompanyNme = selectedRowValue;
    }
}

@"ToContacts" means your storyboard identifier.
3
  • This doesn't answer my question. I know how to segue, however things that are important to me are: 1) The segue occurs when tapping on a row. The design is such that the table view consists of the same options regardless of which button is pressed, however the image at the bottom changes. 2) So for example, when tapping on the first row of the table view, it's important to know the which button have we tapped on in order to segue, since the segue is different depending on which button was tapped.
    – David West
    Jan 22, 2013 at 3:36
  • Create variable call as a value. EX : int btnSelect=0; Then when you click option give different value for each. EX (option 1 : btnSelect=1, option 2 : btnSelect=2, option 3 : btnSelect=3). Then you use didSelectRowAtIndexPath and you can get which option you selected and according to the option pass to other screen.
    – Himesh
    Jan 22, 2013 at 3:53
  • Hmm, this still doesn't apply to what I'm trying to do. Look at the image. My segue depends on two different thing: The button selected and the row in the table view selected. As I said, I'm trying to achieve this: f(element.selected==0) && (IBActionProvider==1) { performSegueWithIdentifier:@"blah" sender.self] but am not sure about whether to put this in the IBAction navBarButtonPressedMethod or to put it in the didSelectRowAtIndexPath method.
    – David West
    Jan 22, 2013 at 5:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.