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.

http://i.imgur.com/GM5eH.png?1

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!

4

1 回答 1

0

首先,您为其他故事板视图命名。它包含左侧面板(故事板标识符:)。

您应该为所有按钮创建 segue 并为其提供标识符。

那么你应该prepareforSegue像这样使用

-(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.
于 2013-01-22T02:56:00.383 回答