How can back to scene from view? - cocos2d-iphone

Ques: I had added the view using the code:
[[[Director sharedDirector] openGLView] addSubview:myView];
But how can I will back to Game scene?
if you are asking how to attach UIKit views and such to a cocos2d-iphone project, you just have to do it like:
[[[Director sharedDirector] window] addSubview:myView];
Updated to cocos 0.7 and now this is:
[[[Director sharedDirector] openGLView] addSubview:myView];

How about just removing your view?
[myView removeFromSuperview];

Related

Getting velocity in scrollView in SwiftUI

I am going create a scrollView and getting the velocity for other actions
the code in UIKit scrollView is
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>)
But SwiftUI Drag Gesture seems cannot get the value when I drag the scrollView It needs to be waiting at the end of the scrolling animation end.
Plz
I have tried
.gesture(
DragGesture().onChange ..
)
But it does not work me

How to create a navigation stack of views in SwiftUI?

In UIKit it is possible to create a navigation view controller with a stack of UViewControllers.
let nav = UINavigationController()
nav.viewControllers = [vc1, vc2, vc3]
How would you achieve same in SwiftUI?
There are navigation buttons that push a view but there is no navigation controller

How to add a right button when specific UIViewController get loaded in Swift 3

I have two different UIStorboards and I am using a UINavigationController to load the pages.
I have a total of three UIViewControllers. Two of them are on the first UIStoryboard and the third one is on the second UIStoryboard.
1) Navigation controller
2) Main Controller
3) Value Screen Controller.
I want to add right button on navigation bar only when value screen controller get loaded. It should not be available on Main view controller.
I tried with this solution but not worked.
Each UIViewController has its own UINavigationItems. So you can just add this right button in your Value Screen Controller by adding this line:
self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: <#T##UIBarButtonSystemItem#>, target: <#T##Any?#>, action: <#T##Selector?#>)
You can place it in func viewDidLoad() if you want it to be place as soon as the UIViewController's view is loaded.

Navigation Bar Background Color Light with Swift 3

I add Navigation Bar in any view controller. But, I'm adding new CollectionView Controller in project. My problem is that I could not add Navigation Bar in Collection View Controller.
So I add Navigation Bar with code. I choose Top Bar- "Inferred" in Attributes Inspector. Here is the code.
//Add Navigation Bar
let height: CGFloat = 65
let navbar = UINavigationBar(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: height))
navbar.delegate = self
UINavigationBar.appearance().barTintColor = UIColor(red: 0.0/255.0, green:49.0/255.0, blue:79.0/255.0, alpha:0.1)
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().isTranslucent = true
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white]
But, the Navigation Bar Background Color in Collection View Controller is a little bit dark than other view controller.
In other view controller, I drag and put navigation bar.
- Navigation Bar style --> Black
- Translucent --> not enabled
- Bar Tint Color --> #00314F
I don't know why Navigation Bar Background Color in Collection View Controller is light than in Collection View Controller.
Please help me how to match Navigation Bar Background Color in all view controller.
If it is not easy to do, is there any ways to add Navigation Bar in CollectionViewController without embedded in Navigation Controller and without code.
It is beacause of the Translucent property of NavigationBar. It gives an effect where the image color looks faded as if a layer has been put on the bar, hence the color looks a little and different. Set off the translucent property of navigation bar as shown below. You can write this code in any lifecycle methods.
self.navigationController?.navigationBar.isTranslucent = false
It is because of translucent i think. When the navigation bar is not translucent, view can't locate behind the navigation bar to show what it has. But when is translucent, view stays behind the navigation bar and with view's color, you see it darker.

How to change titleview of a navigation item inside Tab Bar controller?

So I have created a UITabBarController as my root controller, then added UINavigationController as a tab bar item, and a UIViewController as a navigation item for it.
I want to set an image instead of the navigation item title, so I tried the following in viewDidLoad in the UIViewController, but it didn't work:
UIImage *image = [UIImage imageNamed:#"logo.png"];
self.navigationItem.titleView = [[UIImageView alloc] initWithImage:image];
Any Suggestions?
Sorry for my poor English.
Well guys, I have found out what went wrong!
I should have set the class property for the UIViewController to my custom class controller, that's why viewDidLoad was not being called.
Just follow this tutorial here, and everything should be fine.
http://www.youtube.com/watch?v=LBnPfAtswgw
Now, I want to push another view from the navigation controller?