ipad - lay out a view in Storyboard then load it in a PopOver from code? -
i have relatively complex ui appearing in popover (complex enough doing layout , relationships code pain), button calls created , placed parent view (which exists in storyboard) code.
i've tried making popover segue parent view's viewcontroller object popover content vc, triggering performseguewithidentifier. works, can't figure out how set popover's anchor code appears @ wrong place (squished @ bottom of screen).
is there way set popover segue's anchor dynamically? or can create uipopovercontroller object , view i've put in storyboard it? or there other obvious way i'm not seeing?
please gentle, i'm new here.
ipad ios5.1 xcode4.3.2
alex,
i'm not sure understand you're trying do, let me take stab @ think understand.
for same reason cite (view complexity, etc.), build out views in storyboard , load them action. can instantiate view controller identifier this:
fancyviewcontroller *controller = [[self storyboard] instantiateviewcontrollerwithidentifier:@"fancyviewcontroller"]; this assumes have created uiviewcontroller subclass called fancyviewcontroller , have set type view controller in storyboard.
now, can display view controller in popover controller or can push onto navigation stack. need make sure you've set identifier view controller in storyboard.

also, you'll want instantiate view controller once if use popover controller , update view controllers properties each time action gets triggered. so, if it's tapping button triggers popover, code might this:
- (ibaction)didtapbuttontoshowfancyviewcontroller:(id)sender { if (![self fancyviewcontroller]) { // fancyviewcontrller property of type fancyviewcontroller * fancyviewcontroller = [[[self storyboard] instantiateviewcontrollerwithidentifier:@"fancyviewcontroller"]; // fancyviewpopovercontroller property fancyviewpopovercontroller = [[uipopovercontroller alloc] initwithcontentviewcontroller:fancyviewcontroller]; } // perform setup on fancy controller want every // time action gets triggered here. initialization in if // block above. // display popover sender's frame. i'm assuming // sender uibutton. [fancyviewpopovercontroller presentpopoverfromrect:[sender valueforkey:@"frame"] inview:[self view] permittedarrowdirections:uipopoverarrowdirectionany animated:yes]; } the way set popover's "anchor" dynamically use explicit action calls presentpopoverfromrect:permittedarrowdirections:animated: instead of segue.
i hope helps. let me know if i've misunderstood you're trying do.
best regards.
Comments
Post a Comment