I am stuck in googlemap integration. I am working with google map actually i want to kill a map view on button click as it is consuming too much memory how it can be kill? i just want to unload a map in my app. below is my sample code but it is not working..
(IBAction)menuButtonPressed:(id)sender {
[super menuButtonPressed:sender];
self.mapView_=nil;
}
but not working kindly help me regarding this..
All that you code does is remove the local reference to the map view. As the map is still visible in your view, it won't be released as the view will be holding a strong reference.
Try
- (IBAction)menuButtonPressed:(id)sender {
[super menuButtonPressed:sender];
[self.mapView_ removeFromSuperview];
self.mapView_=nil;
}
Related
I'm using an open source messaging UI library for an app that I'm building. When users start a new conversation I want the "chat view" to appear with the keyboard already up and the cursor on the textfield (similar to most existing chat applications). Is there a way to force the JSQMessagesViewController to appear with the keyboard already up?
I tried implementing this using:
self.keyboardController.textView.becomeFirstResponder()
However, this caused the keyboard to pop up immediately when the view was presented... yet the toolbar would lag behind by about a second (not too much, but painfully noticeable). In addition, this solution seems to disable the keyboard from being dismissed using a downward gesture as it normally does.
Is there something I'm missing that solves this out of box? Or will I have to modify the library to get this bit of functionality... and if so, where do I begin doing that?
try to do like this
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:YES];
[myTextField becomeFirstResponder];
}
--> It will make focus on myTextField and open the keyboard automatically. Hope it may help you.
This worked for me. It's in swift, but should be easy to translate.
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(false)
self.inputToolbar!.contentView!.textView!.becomeFirstResponder()
}
I wanted this with a button click so I added:
[self.inputToolbar.contentView.textView becomeFirstResponder];
If you want yours when it loads add:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self.inputToolbar.contentView.textView becomeFirstResponder];
}
This maybe too late, but in my case I forgot to call super.viewDidAppear(animated) which caused text view to lag behind keyboard. Once I added that call, problem went away.
does anyone knows how to disable the swipe forward and backward feature in ios.
I am using angularjs and stuck in a problem where user can swipe back and forward this disturbs my functionality of the app. any lead would be appreciated.
I don't think you can accomplish exactly what you are trying to do. I have run into this issue as well - where I need to save some piece of data before the user goes back to a previous view controller. Reacting to a button tap is easy with an IBOutlet and some simple logic. But when the user has the ability to swipe to go back with functionality built into UINavigationControllers, it's not so cut and dry now.
Instead of trying to swim against the current, why not use this new ability?
Using viewWillDisappear, check if the current view controller is no longer in self.navigationController's stack. If it isn't than we are Oscar Mike to a different view controller and you should save your data.
-(void) viewWillDisappear:(BOOL)animated {
if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
[self saveImportantData];
}
[super viewWillDisappear:animated];
}
While I'm sure this isn't what you asked for, maybe it is a workaround that will help you.
if u have the access to viewcontroller file,then u can use the above code to disable the screen panning
- (void)viewDidLoad {
[super viewDidLoad];
if ([self.navigationController respondsToSelector:#selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
}
I made a settings tab for the MapView's ViewController and it works fine when I open the MapViews's VC the first time. but when I change the settings after I opened and loaded the mapView the first time the settings that I changed don't apply to the mapView because it did not refresh. Is there a way of refreshing the data of the mapView? I have searched everywhere and couldn't find an answer.
if this question have been answerd before can you link me to it? Thank you.
I'm using the GoogleMaps ios sdk.
and I'm using obj-c.
If your settings just changes the icons, annotations, map markers or layers color , or location of markers or layer, the simplest way to do is clear all the markers and layers you add on the map view and re-add them. For example, implement a refreshMapView method
-(void)refreshMapView
{
[mapView clear];//this line clears all the markers or layers you drew on the mapView.
// then implement your method to re-draw the markers and layers, or load new settings.
// for example, go through your marker list, and add them as follows:
for (id yourobject in yourMarkerArray){
GMSMarker *marker = [GMSMarker markerWithPosition:coordinatesOfMarker];
//custom marker here, set title, or snippets, or icon, etc...
marker.map = mapView;
}
// you can also redraw any map overlay here...
}
Jing's answer to implement a refreshMapView method is good, you could call that in your map view controller's viewWillAppear section.
Make sure you're actually setting the mapView properties in the same scope — i.e., your settings view and your map view may be looking at a different object or changes may be getting discarded. Without seeing the code for how you're trying to modify those settings, it's difficult to say.
I am developing a little MS tweak that adds a view on the Springboard. I want it to be constantly updated so I called it into the
- (void)showSpringBoardStatusBar
Then I create and add the view using this:
[[UIApplication sharedApplication].keyWindow addSubview:view1];
Is this the right way?
But the problem is this view uses a low alpha level to be transparent and every time the view is updated by the showSpringBoardstatus bar another UIView is added onto of it eventually just making the view solid. This also is uneconomical in terms of memory. so then I went back an added what I thought would remove the code:
view1 = nil;
[view1 removeFromSuperview];
But it seems like this doesn't make a difference as it is still there and nothing changes.
I have been searching for the last few days for anything to help me with this but got nothing out of it. All I can think of is that I can't remove an added subview from a key window like I would from a normal view or I just don't how to do it correctly.
Any help would be appreciated. Thank you.
Setting view1 to nil and than calling "removeFromSuperView" might be a bad idea. How about adding the view only once, keeping a reference and updating this reference constantly without adding it to keyWindow again?
I'm encountering a mystery issue when selecting a pin in the mapview iOS6
BTW, it works correctly in iOS 5, i'm not sure what they changed in the map of iOS 6 that produce this issue.
NOTE that when I click on the map, the callout directly go over the pins and shows correctly
any help/clue would be appreciated,
Thanks in advance
the answer might vary a bit depending on how you're implementing your custom callout bubble. This was/is the solution I'm using: Customize the MKAnnotationView callout and I ran into the exact same problem.
Basically, everytime the callout is going to show, I had to bring the subview to the front.
In this case, my custom callout bubble is a class called 'BaseCalloutView' which contains a UIView as its ContentView property (as you can see in the UML diagram at the link above). When the annotation is selected, it triggers the 'animateIn' function of the BaseCalloutView, into which I added:
[self.superview bringSubviewToFront:self];
As I mentioned, your mileage may vary depending on how you're implementing the custom callout bubble. I can provide you with the full code if needed - but to be honest 90% of my code is from the link above.
This solution didn't work for me, however the one did:
Custom Annotation View do not work on iOS6
Sorry not sure how to link answers properly.
In IOS 5 and IOS 6 , I try this and it's ok
the pin never overlap CalloutView.
I use custom calloutview , in file Base calloutView I add this :
- (void)didMoveToSuperview {
[super didMoveToSuperview];
[self.superview bringSubviewToFront:self];
}
I am using same code base, got same problem. [self.superview bringSubviewToFront:self]; doesn't work for me, not matter where did I put it. [annimateIn] or [didMoveToSuperView] or [layoutIfNeeded]
Because this problem went away by finger moving the map a little bit, so I found it is very easy to simulate this effect by put code in - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view. The offset is very small, no visual movement can be noticed at all.
CLLocationCoordinate2D newCenterCoordinate = {self.mapView.region.center.latitude + 0.0000001,
self.mapView.region.center.longitude + 0.0000001};
[self.mapView setCenterCoordinate:newCenterCoordinate animated:NO];