>> Can this be done? Or is there a better way to make my button work both
>> for iPhone and iPad?
> 
> Well, my first question is: can you just put your work in the
> implementation of the unwind selector?

That is the way the work is done.

> The unwind itself will be a no-op
> if the split view controller is not collapsed, but the runtime should
> still invoke your unwind selector. If it doesn't, that's a bug, and you
> should file a Radar and send me the number.
Bug 20566151 iPad cannot Unwind

If someone wants to check this bug, here is how I did it:


1. Create project

I created (in Xcode 6.3) a new iOS Application: Master-Detail Application; 
named it "Dummi" (left all the other things unchanged: i.e Objective-C, 
Universal, no CoreData).


2.      Rename Master Scenes

Looked at Main.storyboard. It has 2 Master Scenes. This I think confusing.

I clicked the yellow "Master" symbol in the first Master Scene, set Attributes 
Inspector → View Controller → Title to "Master iPad".

Same with other "Master" → "Master iPhone".


3.      Run

Run on iPhone:
Back Button is called "Master"

Run on iPad:
Back Button is called "Master iPad"

Strange, but not very important.


4.      Unwinding

Added in MasterViewController:

- (IBAction)doSomethingAndBackToMaster:(UIStoryboardSegue*)segue
{
        DetailViewController *detailViewController = segue.sourceViewController;
        NSLog(@"%s did something with \"%@\", will do: [%@ 
perform]",__FUNCTION__, 
                detailViewController.detailItem, segue);
        [ segue perform ];
}

Added in Detail Scene a UIBarButtonItem to the right of the Navigation Bar; 
Titel = "Do & Back".

Control-dragged from "Do & Back" to red Exit symbol in Master iPhone Scene; 
selected "doSomethingAndBackToMaster:".


5. Run 

iPhone  - tapping on "Do & Back" prints:
2015-04-16 12:16:52.799 Dummi[28069:20737983] -[MasterViewController 
doSomethingAndBackToMaster:] did something with "2015-04-16 05:16:49 +0000", 
will do: [<UIStoryboardSegue: 0x79f386e0> perform]

iPad    - tapping on "Do & Back" prints:
nothing. 


> But while I'm here, I figure I should share some little-known knowledge:
> segues do not need to be attached to a control at all. A segue is
> actually defined by its source and destination view controllers, not by
> any controls that invoke it.
> 
> To create a "manual segue" (that is, one which must be invoked in code,
> rather than by any button action):
> 
> 1. In the Document Outline on the left side of the storyboard editor,
> expand the Master and Detail scenes
> 2. Control-drag from the Detail scene's view controller to the Master
> scene's Exit proxy.
> 3. Choose the unwind selector to create a manual unwind segue that isn't
> attached to any specific control.

No such choice.
I get offered:
Manual Segue
        doSomethingAndBackToMaster:
Nothing else

> 4. On the Properties Inspector for that newly-created segue, give it an
> identifier.
> 5. Wire up your bar button item to a method that uses
> -performSegueWithIdentifier:sender to trigger the unwind.
> 
> —Kyle Sluder

Gerriet.



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to