Possible to use Popover/OptionDialog with table row in iPad?
Hi all the experts out there,
I am trying to use OptionDialog or Popover with table row and I couldn't get it to work. The idea is to create a table of items, and when the user selects one of it, an OptionDialog (or Popover) will show up with the arrow pointing to that row.
For OptionDialog, the emulator will crash if I have
dialog2.show({view:tableviewrow,animated:true});
I also tried setting the view parameter to the label inside the row and it also crashed.
If I remove view:tableviewrow from the function, the dialog box will show up but there is no arrow pointing to the selected row. It will show up in the center of the screen.
I than tried using Popover and has similar result.
Is it not possible to do this? Any idea?
Thanks a lot in advance!
3 Answers
-
I have a workaround:
Just add an invisible view to the clicked row in the the tableview’s click event. And that newly created view can be used as source for the popover.
tableView.addEventListener('click', function(e) { //create the popover here .... //create the "hidden" view where the arrow points to var b1 = Ti.UI.createView({ title:"", height:20, width:1, top:0, right:200 }); //add the view to the clicked row e.row.add(b1); //now this should work popover.show({ view:b1, animated:true }); }
-
Don't know if someone is still having the problem but right now with the postLayout event there is a way to fix the popover misplacement. Moreover we can take care of removing the extra view we created in the row:
... //let's create our extra view var view = Ti.UI.createView({ ... }); view.addEventListener('postlayout',displayPopOver); //add it to our row e.row.add(view); //only when the extra view is rendered we create our popOver : function displayPopOver(){ view.removeEventListener('postlayout', displayPopOver); var popover = Ti.UI.iPad.createPopover({ width: 400, height: 550, title: 'Detail', arrowDirection:Ti.UI.iPad.POPOVER_ARROW_DIRECTION_LEFT, }); //when popOver disappears remove the extraView popover.addEventListener('hide',function(evt) { e.row.remove(view)}) } // end displayPopOver() .....
-
I am having the same issue. I get an error saying that the view must belong to a window.