Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to send data to a popover being created programmatically?
    primarykey
    data
    text
    <p>I'm trying to create a popover for dynamic cells in an iOS tableview, and I'm a little stuck. Apparently, storyboard segues cannot be used with dynamic cells, so I have to do this programmatically. I have a normal ViewController class with the property as follows:</p> <p>SOCommandPopup.h</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; #import "SOCommand.h" @protocol ReturnCommand &lt;NSObject&gt; @required -(void)getCommand:(SOCommand*)command; @end @interface SOCommandPopup : UIViewController &lt;UITextFieldDelegate&gt; @property (nonatomic,strong)SOCommand* command; @property (strong,nonatomic)id&lt;ReturnCommand&gt;delegate ; @end </code></pre> <p>It contains a protocol which is used by another view controller (the one that invokes it), to get data entered in the popover. </p> <p>Popover container ViewController</p> <pre><code>-(void)createPopoverWith:(NSIndexPath*)commandIndex { SOCommandPopup* newPopup = [[SOCommandPopup alloc]init]; editCommandPopup = [[UIPopoverController alloc]initWithContentViewController:newPopup]; editCommandPopup.popoverContentSize = newPopup.preferredContentSize; if(commandIndex) { newPopup.command = [_serverModuleCommands objectAtIndex:commandIndex.row]; } else if(!commandIndex) { NSLog(@"test"); //this fires, when I pass nil newPopup.command = nil; [editCommandPopup presentPopoverFromBarButtonItem:self.btn_addButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; } } </code></pre> <p>The <code>SOCommandPopup</code> class will construct itself based on the <code>command</code> property sent to it. So I want to be able to invoke <code>[self createPopoverWith:someCommand]</code> in the container. However, I don't know how to set its property since it is just a <code>UIPopoverController</code> and not a <code>SOCommandPopup</code>. </p> <p>Any help would be much appreciated, thanks!</p> <p>~Carpetfizz</p> <p>EDIT: For the sake of testing I'm passing <code>nil</code> into <code>createPopoverWith:</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload