[TIMOB-944] accessing detail default popover = crash
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Trivial |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-04-17T01:54:44.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 1.4.0 |
Components | iOS |
Labels | n/a |
Reporter | Nolan Wright |
Assignee | Blain Hamon |
Created | 2011-04-15T02:39:49.000+0000 |
Updated | 2011-04-17T01:54:44.000+0000 |
Description
if you try to save a reference to the popover from the visible event and then use it later, it crashes. here's the code:
var masterWindow = Ti.UI.createWindow({
backgroundColor: '#fdf5e5',
barColor: '#ec4930'
});
var masterNavigationGroup =
Ti.UI.iPhone.createNavigationGroup({
window: masterWindow });
var b = Ti.UI.createButton({
title:'Search',
height:100,
width:100
}); b.addEventListener('click', function()
{
Ti.App.fireEvent('openMasterView');
});
var detailWindow = Ti.UI.createWindow({
backgroundColor: '#f7f0e3', barColor: '#ec4930', rightNavButton: b
});
var detailNavigationGroup =
Ti.UI.iPhone.createNavigationGroup({
window: detailWindow });
var splitWindow = Ti.UI.iPad.createSplitWindow({
detailView: detailNavigationGroup,
masterView: masterNavigationGroup
});
var masterPopover = null;
var masterView = null;
splitWindow.addEventListener('visible', function(e)
{
masterPopover = e.popover;
masterView = e.button
if (e.view == 'detail')
{
e.button.title = "foo";
detailWindow.leftNavButton = e.button;
}
else if (e.view == 'master')
{
detailWindow.leftNavButton = null;
} });
Ti.App.addEventListener("openMasterView", function(d)
{
Ti.API.info('in openMasterView pop ' + masterPopover)
if (masterPopover != null)
{
masterPopover.show({view:masterView});
}
});
splitWindow.open();
The biggest issue here is that I have no idea what the user is trying to accomplish. Why would you show a popover of a button? The wording seems to indicate that they want to show a popover of the master view, but why would you ever do that?
There is an additional problem that the masterView variable appears to be incorrectly set at certain times as far as the context for the app event listener is concerned. Regardless, there are still problems with popovers.
Here is some slightly modified code, which crashes in a different (but vastly more appropriate) way:
Looking into resolving this now.
They are trying to set the value of masterPopover in order to use it later in the app. Seems valid to me.
Yeah, that comment was written before I took a look through some more of the presentation code. There is still some kind of very strange issue with setting masterView = e.button, however, because in the app event listener it wasn't the correct value (although it was the right value in the context of the function which set it).
(from [7fc6a66f81548c8535f270bed0106464fc0cfc65]) [#944 state:open] Fixes to split window buttons. Necessary for upcoming changes to how popovers display. http://github.com/appcelerator/titanium_mobile/commit/7fc6a66f81548c8535f270bed0106464fc0cfc65"> http://github.com/appcelerator/titanium_mobile/commit/7fc6a66f81548...
(from [c28c79c40727235b3481a0d042299b8a408fd22a]) Closes #944: Removed access to the splitview's builtin popover. See the ticket for why. http://github.com/appcelerator/titanium_mobile/commit/c28c79c40727235b3481a0d042299b8a408fd22a"> http://github.com/appcelerator/titanium_mobile/commit/c28c79c407272...
This was a case of burning the village to save it. We shouldn't allow access to the popover that's managed by the split view, because certain magic happens with it - if it's messed with in any way, that magic might not happen (or could appear very odd). Besides, the popover doesn't have anything innate about it beyond being used for this special system: It doesn't automatically hold the master view, for example.
If it's absolutely necessary to display the master view in a non-convential way via popover, you should make your own popover and manage it yourself, to display the master view when required.
Regarding removing access to the Popover in a Splitview.
There is one reason why one would need access to it ... to close it when an event is fired.
If you look at the standard Mail app, when an email is selected from the splitview popover, the app automatically closes the popover and shows the detail window.
Currently in the visible event, having the instance would allow the app to close the popover. With out that access to the object, there is no apparent way to close the default split view Popover.
If there is, please post response.
Thanks
Tim
Looking through the code, there is not currently a way exposed to close an open split view popover. I don't mind the ability to close the split view popover, but I'd much rather it be functionality explicitly added to split view (IE, splitView.closeMainViewPopover() ) rather than restore the previous hack. The previous hack was very error prone and would have caused a great many problems going forward.
So, can we get such a function into the road map for 1.5 or a later release?
Hi,
Was a solution ever put in place for this functionality? It's crucial that we are able to dismiss the popover programmatically, not just from a UX point of view but also because it can cause crashes. For example, if one attempts to close a split window while the popover is still visible, the following crash occurs:
Thanks.