I have a GMSMapView on my storyboard
#property (strong, nonatomic) IBOutlet GMSMapView *gmsMapViewUI;
Using the instructions I am unable to get my this mapView to update to the new coordinates. This had been working for me in the past but I have since restructured the function and seem to be missing some crucial detail to get the map to load correctly again. There are so few lines to my call I must have missed one thing or another. Google SDK doesn't give me any clear information either.
GMSCameraPosition *newCam=[GMSCameraPosition cameraWithLatitude:33 longitude:122 zoom:16];
self.gmsMapViewUI=[GMSMapView mapWithFrame:self.gmsMapViewUI.bounds camera:newCam];
self.gmsMapViewUI.delegate=self;
Have you tried to set the camera only instead of throwing away the GMSMapView created by the storyboard? Like
self.gmsMapViewUI.camera = newCam;
You can also try this to move to a new cameraPosition.
[self.gmsMapViewUI animateToCameraPosition:newCam];
Related
I am following this tutorial: http://www.appcoda.com/ios-programming-sidebar-navigation-menu/
However, I need to be able to access the side menu from the classes view controller as seen in the image . While my first view controller is a login screen that the user needs to login to a a server with. To fix the problem I have made a property inside the reveal view controller #property (strong, atomic, retain) NSString *SWSegueFrontIdentifier;. Then I use the getters and setters to assign which view controller is should to/from. I assign the first value sw_first in view controller and everything is fine. In ViewDidLoad of the classmates view controller, seen in the second image, i assign sw_front. However, even when that is set in the same function, if i try to print the property from the reveal controller, it ends up returning null. However, if I manually switch the SWSegueFrontIdentifier inside the view controller to sw_front it segues just fine, but ends up skipping my view controller, which is my login controller. I just need a way for the side menu to be accessed from my classmates view controller and have not had any luck, because it seems most things on www.cocoacontrols.com are made to use without storyboards and I can't seem to get them to work.
This code returns null:
[self.revealViewController setSWSegueFrontIdentifier:#"sw_front"];
tempMenuButton.target = self.revealViewController;
tempMenuButton.action = #selector(revealToggle:);
NSLog(#"reveal view controller prop2: %#", self.revealViewController.SWSegueFrontIdentifier);
Any ideas on what I can do to get this to work?
EDIT: Only thing that I can think of is some sort of memory retention problem, but I can't seem to figure it out.
after declaring the property
#property (strong, atomic, retain) NSString *SWSegueFrontIdentifier;
ave you used a synthesize to create the getters and setters
#synthesize SWSegueFrontIdentifier = _SWSegueFrontIdentifier;
and then you just do it like this
self.revealViewController.setSWSegueFrontIdentifier =#"sw_front";
This is what I came up with.
I have view control with five button i am setting there properties also is it necessary to release them in dealloc thanks
#interface MainViewController : UIViewController{
IBOutlet UIButton*homeButton;
IBOutlet UIButton*economicDataButton;
IBOutlet UIButton*riskButton;
IBOutlet UIButton*financialImpactButton;
IBOutlet UIButton*probabilitiesButton;
IBOutlet UIButton*enterButton;
}
in ARC you don't have to. the system does it for you. but if you are not using arc then you may do it. even when i use arc or partial arc just for a few classes i still do it. i guess i'm a paranoid coder.:)
EDIT:
well if it is your project and you started it then you must check the box at the beginning for using automatic reference counting or not checking it. if you are using a sample project from someone else then go the target level of your project. then you go to built phases and expand that and see if this phrase is in front of anyone of them. -fobjc-arc. that is for the projects that started without arc and then arc was added to some classes. on the hand if the entire project is arc enabled just declare a iboutlet and try to synthesis it and project will give you an error asking for storng or weak reference. that's how you know that entire project is arc enabled.
happy coding my friend
I am trying to use storyboards in my application. I began well, I have added two view controllers with a button to go from the first to the second.
The problem is in this second view controller: the objects I add on it and link with the code do not work. When I set a breakpoint in the view controller code, the 'self.property' is set to nil, whereas it should be instantiated by the storyboard.
I have been looking for an answer for hours, and I really don't understand the problem, since all the rest seems to be good.
I have tried to write the property in the code (strong/nonatomic, nonatomic/retain and even weak/nonatomic), to link the object directly to the code so that it creates the property automatically, but I never get anything else than "nil" with breakpoints.
viewController.h:
#interface NMLoadingViewController : UIViewController
{
__weak IBOutlet UIProgressView *imageProcessingProgressView;
}
#property (weak, nonatomic) IBOutlet UIProgressView *imageProcessingProgressView;
#end
.m:
#synthesize imageProcessingProgressView;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
// Custom initialization
NSLog(#"INIT.");
}
(amont other lines of irrelevant code)
If I set the breakpoint to the "INIT." line, my imageProcessingProgressView is nil. I can't see a reason for that, I guess I have missed a very little detail...
(Note that I have tried this with other objects, like a UILabel, but it did not work either. Stranger, when I had two objects, one of them had an adress which was not nil, but still it was corrupted and did not show the right object.)
Edit: It was a lot of trouble for nothing... The problem is about the Variable View in XCode, which show my variable to "nil", whereas a log shows me a correct object...
Remove this...
{
__weak IBOutlet UIProgressView *imageProcessingProgressView;
}
...and make the property strong.
Change your log message to...
NSLog(#"INIT: %#", self.imageProcessingProgressView);
...and see if you still have a problem. If you do, then take another look at your storyboard connections.
Make sure NMLoadingViewController is the class on your viewController
First try out the answer by #Eric because I do believe that is the real issue.
Also, make sure that you are actually using the interface builder to hook the controls back to the view controller. This is done by dragging a line from the control back to the property of the view controller.
I used the tabview setup to create an app that has several tabs. One tab has a UIScrollView on it which loads 12 different views into 12 pages. I tried adding a button and imageview to one of the views and now it crashes. I've pored over every single question on here I can find, and have tried every suggested solution, but to no avail. The error that I get is the famous "this class is not key value coding-compliant for the key foo" error. As with everyone else who had this problem, if I disconnect the outlet, it works fine. I've checked and rechecked the class for the nib and it points to the right place.
So I'm not even sure where to go next.
I could post some code, but I don't even know what code would be helpful to post. I'm hoping someone just says, "Um yeah, you can't have a scroll view with multiple views in it and expect to have functionality on each page." That would be helpful!
Page2.h:
#import <UIKit/UIKit.h>
#interface Page2 : UIViewController {
IBOutlet UIImageView *infoImage;
}
#property (retain, nonatomic) UIImageView *infoImage;
(IBAction) showInfo:(id)sender;
#end
Page2.m:
- (IBAction)showInfo:(id)sender {
// do something please!
}
Then in the nib file I CTRL-dragged from "touch-up inside" on my button to the Files Owner and chose "showInfo" ... and I CTRL-dragged from Files Owner down to my UIImageView and chose infoImage.
CRASH
I am not cool enough to insert an image: http://i.stack.imgur.com/KjWhk.png
You still have an outlet connected in your nib that you no longer have defined in your class. You'll see in the inspector that it has turned gray. Disconnect it, and the error should be gone.
are u able to create any other outlet in the same Nib file, as i used to get the same crash, and it got fixed only when i duplicated the same nib, i had implemented almost all methods to solve it. If i am not wrong , this link can help you out https://discussions.apple.com/thread/2431110?start=0&tstart=0
I have sent you the email and attached your project. Hope its working at your end now.
Happy Coding!
The context: I have three views. One Introductory view, an Upload view and the Main view. As classes (With their respective headers) I have the rootViewController (SwitchViewController), IntroViewController and UploadViewController. The first view to be shown is IntroView. The user presses a button (declared in SwitchViewController) that takes them to the UploadView, then in the UploadView they get to choose an image and press the button again to go back to IntroView.
The thing is that while the user gets to pick the image with UIImagePickerController the button to switch views won't hide nor a UIImageView I have with a logo on top of the view(screen). The UIImageView and the UIButton are both declared in SwitchViewController's header.
The code used:
UploadViewController.h
#import [...] //Imports
#class SwitchViewController;
#interface UploadViewController :
UIViewController <UIImagePickerControllerDelegate,
UINavigationControllerDelegate,UIActionSheetDelegate> {
UITextField *imageTextField;
UIImageView *uploadedImage;
SwitchViewController *switchViewController;
[...]
}
#property (nonatomic, retain) SwitchViewController *switchViewController;
#property (nonatomic, retain) IBOutlet UITextField *imageTextField;
#property (nonatomic, retain) IBOutlet UIImageView *uploadedImage;
[...]
#end
UploadViewController.m
[...]
- (IBAction) selectImageButtonPressed {
self.switchViewController.submitButton.hidden = YES;
self.switchViewController.imageLogo.hidden = YES;
[...] //continues
I just begun recently programming in objective-c so please forgive me if the question is very essential. I have looked and am following "Beginning iPhone 3 Development" of APRESS. But even if it helps to greatly understand the basics sometimes I get lost.
PS: If it is clearer to answer the question the SwitchViewController.h and .m snippet codes can be provided if asked. But I thought this text is big as it is.
#Joze i think I may have understood your problem switchViewController is a variable of the class UploadViewController so if you do anything with that variable it wont affect the switchViewController view. so when you are calling the switchViewController view at that time you have to do initWithNibName: bundle: and then hide the button and imageView and also you need to do something like switchViewController.delegate = self; and then call the view modally or what ever way you want it.
PS. i m not sure the that spelling is correct. i dont have xcode at my home.
I hope your problem solves with this.
I solved my problem after refactoring the whole code and changing the general structure of the program itself. Now I have 3 views and each with a viewController to control it. All the switching of views occurs in the Delegate since he has access to everyone. That way I can control every property with every controller, without much difficulty. Changing the property of one of the objects present in one view from another view is difficult and rather inconvenient if not sometimes impossible.
The approach I took when asking this question was short sighted for the application that had to be done. I thank all those who tried to help.