Hi Craig,

As usual, good things are simple.

Simply overrode the Selected method in my derived elements and only
deselect for iPhone. Works as desired!

My sincere thanks,

Guivho.

On 5 June 2012 00:20, Craig Dunn <[email protected]> wrote:
> MWC uses MonoTouch.Dialog extensively!
>
> Looking at the MT.D code, the Element.Selected method is usually implemented
> like this:
>
> public override void Selected (DialogViewController dvc, UITableView
> tableView, NSIndexPath indexPath)
>
> {
>
> // dostuff
>
> tableView.DeselectRow (indexPath, true);
>
> }
>
>
> If you create a custom Element for your app and implement RowSelected
> without 'DeselectRow' it should work. You can probably also just subclass
> the Elements you're already using and just override this one method... you
> might want to make it conditional so that on the iPhone it DOES deselect.
>
> MT.D is pretty extensible (and the source is available too). I'd be
> surprised if you had to re-write as a UITableView...
>
> -craig
>
>
> On Mon, Jun 4, 2012 at 9:48 PM, Guido Van Hoecke <[email protected]> wrote:
>>
>> Craig,
>>
>> Unfortunately, MWC does not use Monotouch.Dialog: it uses its own
>> UITableView which gives a finer control over things.
>>
>> My Master is a DialogViewController, which is also available on the
>> iPhone with some minor conditional stuff, mostly to differentaite
>> between the iPhone and iPad paradigm.
>>
>> I can highlight the entry at NSIndexParth.FromRowSection(0,0) at initial
>> loading time, but fail to keep the selection highlighted whenever an
>> entry is tapped.
>>
>> Here's what I've got to handle this:
>>
>> * in the Dialog Constructor:
>>
>> if (AppDelegate.IsPad)
>>        Dvc.OnSelection += DvcOnOnSelection;
>>
>> * and the DvcOnSelection method:
>>
>> private void DvcOnOnSelection(NSIndexPath nsIndexPath)
>> {
>>        Dvc.TableView.SelectRow(
>>                Dvc.TableView.IndexPathForSelectedRow,
>>                true,
>>                UITableViewScrollPosition.None);
>> }
>>
>> This method is called whenever a row is tapped, but it does not
>> preserve nor force the selection color.
>>
>> Any ideas to preserve the selected color in Monotouch.Dialog?
>> It would be a pity if I had to recode the existing iPhone controller as
>> a lower level TableViewController on the Ipad...
>>
>> Thanks in advance,
>>
>> Guivho.
>>
>>
>>
>>
>> On 3 June 2012 23:58, Craig Dunn <[email protected]> wrote:
>> > The MWC sample does that - both for the master list (landscape view) and
>> > also the mini 'speaker list' for sessions that you can see in this
>> > screenshot.
>> >
>> > https://raw.github.com/xamarin/mobile-samples/master/MWC/Screenshots/iOS/Sessions_iPad.PNG
>> >
>> > the relevant pieces of code are :
>> > * in the SpeakersTableViewSource.cs, we DON'T deselect, so the blue
>> > highlight will remain
>> >
>> > if (AppDelegate.IsPhone) tableView.DeselectRow (indexPath, true);
>> >
>> >
>> >
>> > * in SessionView.cs we set the selection to a particular row when
>> > loading
>> >
>> > if (AppDelegate.IsPad) {
>> >
>> > // set the highlight for whatever speaker is showing in the other column
>> > (only iPad, obviously)
>> >
>> >    if (speakerTable.IndexPathForSelectedRow == null)
>> >
>> >       speakerTable.SelectRow (NSIndexPath.FromRowSection (0,0), true,
>> > UITableViewScrollPosition.Top);
>> >
>> >    else
>> >
>> >       speakerTable.SelectRow (speakerTable.IndexPathForSelectedRow,
>> > true,
>> > UITableViewScrollPosition.Top);
>> >
>> >
>> > HTH
>> > craig
>> >
>> >
>> > On Sun, Jun 3, 2012 at 10:38 PM, Guido Van Hoecke <[email protected]>
>> > wrote:
>> >>
>> >> Hi,
>> >>
>> >> I'm working at a universal app where I use the wonderfull
>> >> MTSplitViewController when ran on the iPad
>> >> (Thank you René).
>> >>
>> >> Both Master and Detail panes use DialogViewControllers
>> >> (Thank you Miguel).
>> >>
>> >> Selecting an element on the Master creates and pushes the corresponding
>> >> DialogController onto the UINavigationController associated with the
>> >> Detail pane.
>> >>
>> >> This interaction works like a charm!
>> >>
>> >> When I tap an element in the Master pane, the blue selection bar fades
>> >> out, which is the normal expected behaviour. However, for a Master pane
>> >> it would be desirable that this selection color would not diappear,
>> >> leaving a clear trace of the selected option that corresponds to the
>> >> current Detail pane content, as a kind of the 'Active menu choice'.
>> >>
>> >> I dare hope that this can be easily achieved, but I've stackoverflowed
>> >> and googled around without success.
>> >>
>> >> Any ideas or suggestions?
>> >>
>> >> Thanks in advance,
>> >>
>> >>
>> >> Guido
>> >>
>> >> --
>> >> You will be surprised by a loud noise.
>> >>
>> >> http://vanhoecke.org ... and go2 places!
>> >> _______________________________________________
>> >> MonoTouch mailing list
>> >> [email protected]
>> >> http://lists.ximian.com/mailman/listinfo/monotouch
>> >
>> >
>
>
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to