uiviewcontroller of smaller size
up vote
1
down vote
favorite
I am new to iOS development and am trying to make a custom toast by using UIViewController of smaller size and presenting it modally. I want that when the view controller is presented, the background screen remains responsive (clickable/scrollable) but at the moment, the background screen becomes unresponsive until the presented view controller is dismissed. Any help in the right direction would be appreciated.
Thanks!
Edit 1:
This is the function inside NotificationToastViewController which is called to show the toast.
class func popup(with presentable: NotificationToastPresentable, onViewDidAppear: (() -> ())? = nil, onDismiss: ((CloseStatus) -> ())? = nil, bool1: Bool = false, bool2: Bool = false)
let popupViewController = NotificationToastViewController()
popupViewController.modalTransitionStyle = .crossDissolve
popupViewController.modalPresentationStyle = .overCurrentContext
let _ = popupViewController.view
popupViewController.configureWith(presentable)
popupViewController.onViewDidAppear = onViewDidAppear
popupViewController.onDismiss = onDismiss
if bool1
popupViewController.statusLabelConstraintToBottom?.constant = 12.0
popupViewController.statusLabelLeadingConstraint?.constant = 10.0
popupViewController.statusLabelConstraintWithIcon?.isActive = false
else
popupViewController.statusLabelConstraintToBottom?.isActive = false
popupViewController.statusLabelLeadingConstraint?.isActive = false
if bool2
popupViewController.heightConstrainOfCtaButton?.isActive = false
UIApplication.shared.topMostViewController()?.present(popupViewController, animated: true)
This is the view hierarchy in the xib:
ios swift uiviewcontroller toast presentviewcontroller
add a comment |
up vote
1
down vote
favorite
I am new to iOS development and am trying to make a custom toast by using UIViewController of smaller size and presenting it modally. I want that when the view controller is presented, the background screen remains responsive (clickable/scrollable) but at the moment, the background screen becomes unresponsive until the presented view controller is dismissed. Any help in the right direction would be appreciated.
Thanks!
Edit 1:
This is the function inside NotificationToastViewController which is called to show the toast.
class func popup(with presentable: NotificationToastPresentable, onViewDidAppear: (() -> ())? = nil, onDismiss: ((CloseStatus) -> ())? = nil, bool1: Bool = false, bool2: Bool = false)
let popupViewController = NotificationToastViewController()
popupViewController.modalTransitionStyle = .crossDissolve
popupViewController.modalPresentationStyle = .overCurrentContext
let _ = popupViewController.view
popupViewController.configureWith(presentable)
popupViewController.onViewDidAppear = onViewDidAppear
popupViewController.onDismiss = onDismiss
if bool1
popupViewController.statusLabelConstraintToBottom?.constant = 12.0
popupViewController.statusLabelLeadingConstraint?.constant = 10.0
popupViewController.statusLabelConstraintWithIcon?.isActive = false
else
popupViewController.statusLabelConstraintToBottom?.isActive = false
popupViewController.statusLabelLeadingConstraint?.isActive = false
if bool2
popupViewController.heightConstrainOfCtaButton?.isActive = false
UIApplication.shared.topMostViewController()?.present(popupViewController, animated: true)
This is the view hierarchy in the xib:
ios swift uiviewcontroller toast presentviewcontroller
1
It is easy to add a custom UIView as toast to the view of UIViewController directly rather presenting it in the way modally. Even you can make it as reusable and can add it where ever you want by setting up the frame of the view.
– Sateesh
Nov 10 at 13:08
If you don't like view you can add container views to any viewcontroller. But for the sake of simplicity and reusability adding view is good choice .
– guru
Nov 10 at 13:27
@Sateesh How do you show a custom uiview as toast? I have created an xib for the custom uiview. I feel that the reason for it blocking might be that i am using safeview to add constraints for the custom uiview and that might be the reason it completely blocks the ui since safe view occupies the entire screen?
– Priyanshu Goyal
Nov 11 at 8:29
@Priyanshu, can you please share the code what you have tried so far, if you don't mind ?
– Sateesh
Nov 11 at 8:32
@Sateesh please check the edit.
– Priyanshu Goyal
Nov 11 at 17:51
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am new to iOS development and am trying to make a custom toast by using UIViewController of smaller size and presenting it modally. I want that when the view controller is presented, the background screen remains responsive (clickable/scrollable) but at the moment, the background screen becomes unresponsive until the presented view controller is dismissed. Any help in the right direction would be appreciated.
Thanks!
Edit 1:
This is the function inside NotificationToastViewController which is called to show the toast.
class func popup(with presentable: NotificationToastPresentable, onViewDidAppear: (() -> ())? = nil, onDismiss: ((CloseStatus) -> ())? = nil, bool1: Bool = false, bool2: Bool = false)
let popupViewController = NotificationToastViewController()
popupViewController.modalTransitionStyle = .crossDissolve
popupViewController.modalPresentationStyle = .overCurrentContext
let _ = popupViewController.view
popupViewController.configureWith(presentable)
popupViewController.onViewDidAppear = onViewDidAppear
popupViewController.onDismiss = onDismiss
if bool1
popupViewController.statusLabelConstraintToBottom?.constant = 12.0
popupViewController.statusLabelLeadingConstraint?.constant = 10.0
popupViewController.statusLabelConstraintWithIcon?.isActive = false
else
popupViewController.statusLabelConstraintToBottom?.isActive = false
popupViewController.statusLabelLeadingConstraint?.isActive = false
if bool2
popupViewController.heightConstrainOfCtaButton?.isActive = false
UIApplication.shared.topMostViewController()?.present(popupViewController, animated: true)
This is the view hierarchy in the xib:
ios swift uiviewcontroller toast presentviewcontroller
I am new to iOS development and am trying to make a custom toast by using UIViewController of smaller size and presenting it modally. I want that when the view controller is presented, the background screen remains responsive (clickable/scrollable) but at the moment, the background screen becomes unresponsive until the presented view controller is dismissed. Any help in the right direction would be appreciated.
Thanks!
Edit 1:
This is the function inside NotificationToastViewController which is called to show the toast.
class func popup(with presentable: NotificationToastPresentable, onViewDidAppear: (() -> ())? = nil, onDismiss: ((CloseStatus) -> ())? = nil, bool1: Bool = false, bool2: Bool = false)
let popupViewController = NotificationToastViewController()
popupViewController.modalTransitionStyle = .crossDissolve
popupViewController.modalPresentationStyle = .overCurrentContext
let _ = popupViewController.view
popupViewController.configureWith(presentable)
popupViewController.onViewDidAppear = onViewDidAppear
popupViewController.onDismiss = onDismiss
if bool1
popupViewController.statusLabelConstraintToBottom?.constant = 12.0
popupViewController.statusLabelLeadingConstraint?.constant = 10.0
popupViewController.statusLabelConstraintWithIcon?.isActive = false
else
popupViewController.statusLabelConstraintToBottom?.isActive = false
popupViewController.statusLabelLeadingConstraint?.isActive = false
if bool2
popupViewController.heightConstrainOfCtaButton?.isActive = false
UIApplication.shared.topMostViewController()?.present(popupViewController, animated: true)
This is the view hierarchy in the xib:
ios swift uiviewcontroller toast presentviewcontroller
ios swift uiviewcontroller toast presentviewcontroller
edited Nov 11 at 17:50
asked Nov 10 at 12:07
Priyanshu Goyal
7310
7310
1
It is easy to add a custom UIView as toast to the view of UIViewController directly rather presenting it in the way modally. Even you can make it as reusable and can add it where ever you want by setting up the frame of the view.
– Sateesh
Nov 10 at 13:08
If you don't like view you can add container views to any viewcontroller. But for the sake of simplicity and reusability adding view is good choice .
– guru
Nov 10 at 13:27
@Sateesh How do you show a custom uiview as toast? I have created an xib for the custom uiview. I feel that the reason for it blocking might be that i am using safeview to add constraints for the custom uiview and that might be the reason it completely blocks the ui since safe view occupies the entire screen?
– Priyanshu Goyal
Nov 11 at 8:29
@Priyanshu, can you please share the code what you have tried so far, if you don't mind ?
– Sateesh
Nov 11 at 8:32
@Sateesh please check the edit.
– Priyanshu Goyal
Nov 11 at 17:51
add a comment |
1
It is easy to add a custom UIView as toast to the view of UIViewController directly rather presenting it in the way modally. Even you can make it as reusable and can add it where ever you want by setting up the frame of the view.
– Sateesh
Nov 10 at 13:08
If you don't like view you can add container views to any viewcontroller. But for the sake of simplicity and reusability adding view is good choice .
– guru
Nov 10 at 13:27
@Sateesh How do you show a custom uiview as toast? I have created an xib for the custom uiview. I feel that the reason for it blocking might be that i am using safeview to add constraints for the custom uiview and that might be the reason it completely blocks the ui since safe view occupies the entire screen?
– Priyanshu Goyal
Nov 11 at 8:29
@Priyanshu, can you please share the code what you have tried so far, if you don't mind ?
– Sateesh
Nov 11 at 8:32
@Sateesh please check the edit.
– Priyanshu Goyal
Nov 11 at 17:51
1
1
It is easy to add a custom UIView as toast to the view of UIViewController directly rather presenting it in the way modally. Even you can make it as reusable and can add it where ever you want by setting up the frame of the view.
– Sateesh
Nov 10 at 13:08
It is easy to add a custom UIView as toast to the view of UIViewController directly rather presenting it in the way modally. Even you can make it as reusable and can add it where ever you want by setting up the frame of the view.
– Sateesh
Nov 10 at 13:08
If you don't like view you can add container views to any viewcontroller. But for the sake of simplicity and reusability adding view is good choice .
– guru
Nov 10 at 13:27
If you don't like view you can add container views to any viewcontroller. But for the sake of simplicity and reusability adding view is good choice .
– guru
Nov 10 at 13:27
@Sateesh How do you show a custom uiview as toast? I have created an xib for the custom uiview. I feel that the reason for it blocking might be that i am using safeview to add constraints for the custom uiview and that might be the reason it completely blocks the ui since safe view occupies the entire screen?
– Priyanshu Goyal
Nov 11 at 8:29
@Sateesh How do you show a custom uiview as toast? I have created an xib for the custom uiview. I feel that the reason for it blocking might be that i am using safeview to add constraints for the custom uiview and that might be the reason it completely blocks the ui since safe view occupies the entire screen?
– Priyanshu Goyal
Nov 11 at 8:29
@Priyanshu, can you please share the code what you have tried so far, if you don't mind ?
– Sateesh
Nov 11 at 8:32
@Priyanshu, can you please share the code what you have tried so far, if you don't mind ?
– Sateesh
Nov 11 at 8:32
@Sateesh please check the edit.
– Priyanshu Goyal
Nov 11 at 17:51
@Sateesh please check the edit.
– Priyanshu Goyal
Nov 11 at 17:51
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
You can do something of this sort:
var vc = SecondController()
self.addChild(vc)
self.view.addSubview(vc.view!)
vc.view.translatesAutoresizingMaskIntoConstraints = false
vc.view.leftAnchor.constraint(equalTo: self.view.leftAnchor, constant: 200).isActive = true
vc.view.topAnchor.constraint(equalTo: self.view.topAnchor, constant: 300).isActive = true
vc.view.bottomAnchor.constraint(equalTo: self.view.bottomAnchor, constant: 0).isActive = true
vc.view.rightAnchor.constraint(equalTo: self.view.rightAnchor, constant: 0).isActive = true
Where SecondViewController is another ViewController class, which you have to add as a child Controller to your home controller and then set the constraints of the second controller's view. I believe the result of such an implementation is what you are trying to achieve.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You can do something of this sort:
var vc = SecondController()
self.addChild(vc)
self.view.addSubview(vc.view!)
vc.view.translatesAutoresizingMaskIntoConstraints = false
vc.view.leftAnchor.constraint(equalTo: self.view.leftAnchor, constant: 200).isActive = true
vc.view.topAnchor.constraint(equalTo: self.view.topAnchor, constant: 300).isActive = true
vc.view.bottomAnchor.constraint(equalTo: self.view.bottomAnchor, constant: 0).isActive = true
vc.view.rightAnchor.constraint(equalTo: self.view.rightAnchor, constant: 0).isActive = true
Where SecondViewController is another ViewController class, which you have to add as a child Controller to your home controller and then set the constraints of the second controller's view. I believe the result of such an implementation is what you are trying to achieve.
add a comment |
up vote
0
down vote
You can do something of this sort:
var vc = SecondController()
self.addChild(vc)
self.view.addSubview(vc.view!)
vc.view.translatesAutoresizingMaskIntoConstraints = false
vc.view.leftAnchor.constraint(equalTo: self.view.leftAnchor, constant: 200).isActive = true
vc.view.topAnchor.constraint(equalTo: self.view.topAnchor, constant: 300).isActive = true
vc.view.bottomAnchor.constraint(equalTo: self.view.bottomAnchor, constant: 0).isActive = true
vc.view.rightAnchor.constraint(equalTo: self.view.rightAnchor, constant: 0).isActive = true
Where SecondViewController is another ViewController class, which you have to add as a child Controller to your home controller and then set the constraints of the second controller's view. I believe the result of such an implementation is what you are trying to achieve.
add a comment |
up vote
0
down vote
up vote
0
down vote
You can do something of this sort:
var vc = SecondController()
self.addChild(vc)
self.view.addSubview(vc.view!)
vc.view.translatesAutoresizingMaskIntoConstraints = false
vc.view.leftAnchor.constraint(equalTo: self.view.leftAnchor, constant: 200).isActive = true
vc.view.topAnchor.constraint(equalTo: self.view.topAnchor, constant: 300).isActive = true
vc.view.bottomAnchor.constraint(equalTo: self.view.bottomAnchor, constant: 0).isActive = true
vc.view.rightAnchor.constraint(equalTo: self.view.rightAnchor, constant: 0).isActive = true
Where SecondViewController is another ViewController class, which you have to add as a child Controller to your home controller and then set the constraints of the second controller's view. I believe the result of such an implementation is what you are trying to achieve.
You can do something of this sort:
var vc = SecondController()
self.addChild(vc)
self.view.addSubview(vc.view!)
vc.view.translatesAutoresizingMaskIntoConstraints = false
vc.view.leftAnchor.constraint(equalTo: self.view.leftAnchor, constant: 200).isActive = true
vc.view.topAnchor.constraint(equalTo: self.view.topAnchor, constant: 300).isActive = true
vc.view.bottomAnchor.constraint(equalTo: self.view.bottomAnchor, constant: 0).isActive = true
vc.view.rightAnchor.constraint(equalTo: self.view.rightAnchor, constant: 0).isActive = true
Where SecondViewController is another ViewController class, which you have to add as a child Controller to your home controller and then set the constraints of the second controller's view. I believe the result of such an implementation is what you are trying to achieve.
answered Nov 10 at 13:15
SWAT
551311
551311
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238787%2fuiviewcontroller-of-smaller-size%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
It is easy to add a custom UIView as toast to the view of UIViewController directly rather presenting it in the way modally. Even you can make it as reusable and can add it where ever you want by setting up the frame of the view.
– Sateesh
Nov 10 at 13:08
If you don't like view you can add container views to any viewcontroller. But for the sake of simplicity and reusability adding view is good choice .
– guru
Nov 10 at 13:27
@Sateesh How do you show a custom uiview as toast? I have created an xib for the custom uiview. I feel that the reason for it blocking might be that i am using safeview to add constraints for the custom uiview and that might be the reason it completely blocks the ui since safe view occupies the entire screen?
– Priyanshu Goyal
Nov 11 at 8:29
@Priyanshu, can you please share the code what you have tried so far, if you don't mind ?
– Sateesh
Nov 11 at 8:32
@Sateesh please check the edit.
– Priyanshu Goyal
Nov 11 at 17:51