send MKMapView to back in iOS - ios

I have MKMapView on which and I want to display UIView dynamically over the MapView but view never comes to the front. So, what is the solution to this problem?

Try to call the below method. Where you are want show UIView.
yourViewObject.layer.zPosition = 1

Try to call the below method when you wants to bring the view to the front.
[self.view bringSubviewToFront:yourView];
Else
Create a view above the MkMapView and Dynamically Show/hide the view using the following:
[yourView setHidden:NO];

Simply use:
[self.view bringSubviewToFront:yourView];
or
If you are adding your view in mapView,
[mapView bringSubviewToFront:yourView];
If it does not work then please post some of your code.

Related

Spinner on top with many other `UIView`

I'm trying to find why my spinner is not visible.
I have a custom UIActivityIndicatorView. I want to put it on the top of my custom UITableViewCell.
Here is my code:
[downloadingSpinner startSpinner];
Where startSpinner is
- (void) startSpinner{
[self setHidden:NO];
[spinner startAnimating];
}
When I call this startSpinner method, I can't see my spinner. I directly tried to solve my problem with this code:
[self.cellView bringSubviewToFront:downloadingSpinner];
Where cellView is the main view of my cell.
I also tried this code:
downloadingSpinner.layer.zPosition = 1000;
I finally checked the subviews of my main view (cellView). I can see 14 views and le 13th is my custom spinner.
I tried to change the order on the storyboard like this:
I don't have any other idea to put this spinner on top.
I simply add
[self.cellView bringSubviewToFront:downloadingSpinner];
just after I've added my custom UIScrollView. Thank you for your help and I hope this will help someone else.

Why do I get a black screen when I insert a subview?

Using the following code to insert a subview in my UIView I get presented with a black screen. Can someone tell me why?
CJGBoardLabels* whiteLabels = [[CJGBoardLabels alloc] initWithFrame:self.frame
andOrientation:#"white"
andOrigin:self.boardOrigin
andSquareSize:_squareSize
andHorizontalOffset:_horizontalOffset
andVerticalOffset:_verticalOffset];
[self insertSubview:whiteLabels aboveSubview:self];
I get the same result with the following line too:
[self insertSubview:whiteLabels belowSubview:self];
Don't add subviews in the drawRect: method. Instead, use the actual triggering method to add the subviews, and preferably get the controller to add the subviews (not the view itself). So, call addSubview: in the controllers viewDidLoad or an action method.

How do I stop the SearchBar to open on my UITableView instead of over my entire view?

I'm working on an App which main view consists of a MapView and a TableView, similar to the interface of the Foursquare-App. Now the problem I have is that when I hit the search bar of the App, the search window opens over the entire screen - but I'd only want it to open over the TableView.
Does any of you have an idea how to change the behaviour of the SearchBar so that it only laps over its "own" tableView and not the map view?
Here's the two images basicly describing the problem:
//The view without search. The search should come up over the table view.
// but it does not instead covers the whole map.
//Short edit: The map is actually a MapBox map, shouldn't change anything on the topic.
This is a very interesting question... I never tried something like this but I think that a possible way to do could be:
create a view controller with a searchDisplayController that I'll call SearchViewController
SearchViewController *searchVC = [[SearchViewController alloc] init]
and on the view controller that contain the map
[self addChildViewController:searchVC];
// assuming an Y offset of 200 pixel, but you can get the mapView height ... it's better
searchVC.view.frame = CGRectMake(0.0f, 200.0f, self.view.frame.size.width, self.view.frame.size.height-200);
[self.view addSubview:searchVC.view];
if ([searchVC respondsToSelector:#selector(didMoveToParentViewController:)]) {
[searchVC didMoveToParentViewController:self];
}
This probably will not work perfectly but could a starting point... a I said I never tried, let me know if it works
You add your search bar on view I think
you need to add search bar on HeaderView of table view
I think it will be work..

IOS: disable gesture in a viewcontroller

In my app I have this situation:
I have my main viewcontroller where I alloc a "flipwiecontroller" and add its view in this way
self.flipViewController.view.frame = CGRectMake (...);
[self.view addSubview:self.flipViewController.view];
and at this flipViewController I add some gesture (as pangesture, swipegesture and tapgesture for some control that I use on it)
when I press a button in this view I alloc another viewcontroller "paintingviewcontroller" in this way
[self.view addSubview:paintingViewController.view];
in this second view controller I have some buttons and another function, but when I try to do a swipegesture or a tapgesture it recognize the events of my "flipviewcontroller"
I don't understand, if I add a view controller over another viewcontroller, why gesture of flipviewcontroller are active yet?
thnaks
Maybe you are disabling userIntercation on the paintingViewController, then, it's events are sent to his superview.
Also you can use [UIView removeGestureRecognizer:UIGestureRecognizer] to remove gestures.
How did you add the gesture recognizers? They should be added to the view, not the window. Perhaps that's the issue.
In case you have something like this:
[self.view.window addGestureRecognizer:panGestureRecognizer];
You should change it to this:
[self.view addGestureRecognizer:panGestureRecognizer];

Use objectAtIndex:indexPath.row selection to change a scrollview image

I am developing an iOS app that requires the user to search a list in a secondary view, select an entry in the list, and this then closes the view, and adjusts the mainViewController scrollview image to a specific location.
I have stored the selected entry in a variable, but I can't get the view to close, or figure out how to reset the scrollview using my variable. Any help is welcome.
Where you save the selection, set the mainViewController's content offset.
Then if you displayed your secondary view by [view addSubView:]
Call [secondViewController.view removeFromSuperView];
How are you displaying the view you want to close. If you are using
[self.view addSubview:someView] then you can call [someView removeFromSuperview];. If your problem is that your trying to have the view close its self, you can create a function - (void)closeSomeView in your main viewController that closes the view.
As for adjusting the scrollView you just need to create a CGPoint and do something like this
CGPoint somePoint = CGPointMake(xPosition, yPosition);
[scrollView setContentOffset:somePoint];

Resources