0

I've seen lots of topics about this but i could not get this to work as i wanted, i'm sorry that this will look like a duplicate. What i'm tyring to do :

Show a view from a storyboard VC (or a .xib, it's really up to what's "best") as if it was an alert. The user has to interact with it and then dismiss it.

Here is what i have :

A viewcontroller in my storyboard ; its linked to the corresponding .h and .m files and everything works fine on that side.

Note : That viewcontroller is "alone", there is no segue leading to it.

Now i'm in my active VC from my app flow, and i'm doing this :

ADFViewController *adf = [[ADFViewController alloc]initWithNibName:@"ADFView" bundle:[NSBundle mainBundle]];
adf.xxx = yyy // just setting some data that the user interacts with.
[self.view addSubview:adf.view];

(The VC has a button that does [self.view removeFromSuperview]; to dismiss itself when the user decides to do so.)

I've also tried using this :

adf = [self.storyboard instantiateViewControllerWithIdentifier:@"ADFViewController"];

Both don't work or "almost" work.

They're linked like they should, the storyboard and Nib name corresponds (i've tried both).

As a result I just get a blank screen. The view size is 300x300 so It should at least appear somewhat on my screen. But all i get is a blank screen (the view background).

When that is working, I intend to make the background transparent so it really looks like an alert but i'm not even up to that point. And maybe i'm struggling even though i'm going in the wrong direction.

Questions : Am i doing something wrong? Is this the right way of achieving this? What should I do?

Thanks a lot for your time.

Gil Sand
  • 5,802
  • 5
  • 36
  • 78
  • You want to implement a custom transition. Check out the 'Custom Transitions Using ViewControllers' from [wwdc 2013](https://developer.apple.com/videos/wwdc/2013/) – Mike Pollard Oct 29 '14 at 17:48

1 Answers1

0

Getting a view to look and behave like an alert (with the transparent background, etc.) takes some work because you can't subclass UIAlertView. I would recommend using an already-built customizable UIAlertView-looking dialogue. There are a couple listed on this question:

UIAlertView addSubview in iOS7

These basically just take a view as input, so you can just pass in your view controller's view and everything else will be taken care of for you.

Community
  • 1
  • 1
socom1880
  • 340
  • 3
  • 12