0

This is my question,think that I have two views. in the first view there is a imageview(with a image) and a button.When I press the button then it load second view(with storyboard segue kind is present modally).when that view loads, I want to set the first view, through the second view(should be transparent).

I tried with setting secondview's defatul view background color to default but it gives black.how can I do that.

caldera.sac
  • 4,918
  • 7
  • 37
  • 69

3 Answers3

1

Oh i fixed you issue after a few minutes test... I found that segue has a property named presentation,like this: enter image description here

you may change the property to Over Current Context and it works

纪忠懿
  • 124
  • 8
  • you can see [Present a transparent modal UIViewController]http://stackoverflow.com/questions/25260774/present-a-transparent-modal-uiviewcontroller – 纪忠懿 Jan 20 '16 at 13:35
1

Select your secondviewcontroller goto attribute inspector then select Transition style to 'cover vertical' and presentation to 'over current context'

and write the code for presentviewcontroller to present your second view controller modally in firstviewcontroller.

sanjeet
  • 1,539
  • 15
  • 37
  • where to write code for `presentviewcontrller` thing, I'm getting a problem @sanjeet – caldera.sac Jan 21 '16 at 07:32
  • at the place of click event – sanjeet Jan 21 '16 at 07:38
  • @snjeet, I'm passing values from `second view` to `firstview`, if the segue `presentation` is `over current context` it does not update the first view's values with which I passed. but segue `presentation` is any other, it works fine.why is that. – caldera.sac Jan 21 '16 at 07:40
  • You can use Delegate. – 纪忠懿 Jan 21 '16 at 08:01
  • before the second view will present .The App will call the function(- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender) in firstView if you implement it.You can set a segue identify in storyboard and check it in this function .Get the Second view instance and do what you wanna do. if ([segue.identifier isEqualToString:@"segue"]) { ViewController1 *vc = [segue destinationViewController]; [vc setDelegate:self]; } – 纪忠懿 Jan 21 '16 at 08:05
0

You can add the view of one viewcontroller to another as a subview. This way the code for each viewcontroller is in it's own class, but they are displayed on top of each other.

MyViewController *viewController = [[MyViewController alloc] init];
[viewControllerA.view setFrame:CGRectMake(x, y, width, height)];
[self.view addSubview:viewController.view];
PaulDaPigeon
  • 303
  • 2
  • 12