Question

in my application I have a UIView object in second view controller. Now I want to display the UIView as a popup or sub view when I click the button from first view controller. Please tell me how to do this? I have seen many solution for the nib files but I didn't find any for storyboard.

I have connected the IBOulet of view in my second view controller.

@property (strong, nonatomic) IBOutlet UIView *popview;

And i have imported the second view controller in my firstview please tell me how to make this one i have been stuck here for long time please help me out on this one.

Thanks.

Was it helpful?

Solution

In your FirstViewController which has UIView *popview:

- (void)viewDidLoad
{
  [super viewDidLoad];
  // you don't want to show PopView
  self.popview.alpha = 0;
}

- (void) showPopView
{
  //you want to show PopView
  self.popview.alpha = 1;
}

OTHER TIPS

Try Adding this in your code

-(void)viewDidLoad

{
popView.hidden=true;

}

and when ever user clicks an action change the hidden property to false just like

-(IBAction)AnyActionPerferformed:(id)sender

{

popView.hidden=false;

}

You can Learn about this from

https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/AboutViewControllers/AboutViewControllers.html

enter image description hereYou don't need an extra UIViewController

  1. In your storyboard, drag a new UIView to your view controller. (It will be your popup view)
  2. Link to your view controller. (@property (strong, nonatomic) IBOutlet UIView *popview;)
  3. When you want to hide popview set it's alpha to 0.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top