Re: Master - Detail: How to get back?
Re: Master - Detail: How to get back?
- Subject: Re: Master - Detail: How to get back?
- From: Kyle Sluder <email@hidden>
- Date: Thu, 16 Apr 2015 07:42:18 -0700
On Apr 15, 2015, at 10:49 PM, Gerriet M. Denkmann <email@hidden> wrote:
>
>
>>> 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.
You should file this as a separate Radar.
>
> 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.
Again, please file this as a separate Radar. (Are you sure it doesn’t say “Master…” on iPhone? That is, does it really say “Master iPhone” but it’s being truncated?)
>
>
> 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 ];
You should not be sending -perform yourself. The segue runtime sends -perform to the unwind segue itself. You are given a pointer to the segue object so that you can inspect its source and destination view controllers and its identifier, so you may choose what work you need to perform in your unwind method.
> }
>
> 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.
Thanks, for filing. That’s definitely unfortunate.
>
>
>> 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
That’s what you should see. Perhaps the title of the menu should be “Unwind Segue”, but right now it’s titled “Manual Segue” to emphasize that this is an unwind segue which you must invoke yourself via -performSegueWithIdentifier:sender:.
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden