Stray MKMapView on my view controller - iphone

My view controller has decided to add a random MKMapView object, despite only declaring one in the .h file. Originally I had used a .xib to configure the view, but that didn't work correctly and I did it all programmatically. You'll see in the attached image my defined map (top) and a small slice of a map at the bottom. The bottom map is the same height as my toolbar, which I find weird. Where could I look to see a random MKMapView object being declared?

Hard to say but I can tell you this looks like a view hierarchy/controller/framing issue since the fragment looks to be exactly the size of a navigation bar.

Related

Get the current UIView's ID objective-c iphone

How can I get the current UIView's ID so that I can use it later without using an IBOutlet?
I would like to add an image over the top of my app but I'm switching views frequently and would like to be able to add the image to the current view because it would show up in my second view
Thnx in advance.
You can't access a UIView by ID in the way that you can on Android devices. IBOutlets are the equivalent for connecting graphical layouts to code.
Based in your comment, the appropriate thing for you to do is to be adding the overlay view at a higher level in the view hierarchy. If you have two views that could be displayed at any given time, and you want to make sure you can cover either of them regardless of which is in place, add your overlay view to the superview of those two. This works all the way up to using the UIWindow object that your App Delegate has, which will let you overlay on top of everything (this is essentially how UIAlertViews work, for example.)
You could set the UIView's tag attribute. Then you can reference it from the superview with
- (UIView *)viewWithTag:(NSInteger)tag

UIView code vs interface builder

I have defined a UIView in the header file named rectangle0
I got a question in regards to IB vs coding a view. Please see the following code example:
rectangle0.frame = CGRectMake(0.0, 70.0, 320.0, 190.0);
Now I can re-create the look of the view easy enough in IB except for the coordinates which are greyed out.
So by calling this code in an IBAction after designing the UIView in IB I can display in the app.
[self.view addSubview:rectangle0];
Now the last line of code will call this view to appear at the set coordinates if I code it - but if I build in interface builder I can make it look exactly the same, but it appears from Y coordinate 20 (just under the status bar) and I can't set the coordinate upon calling it - is there a way to do this??
The UIView is being build outside of the ViewController and then linked to it in the connections inspector.
cheers Jeff
I have added an image to show what screen I am using - as you can see the x and y coordinates are greyed out, it would be great if I can set those to something else.
A view inside the NIB is just an object like any other. It is made to be reusable and I believe that is the key point that resulted in the coordinates being greyed out.
Greying out the position makes the developer worry about where is the view going to be placed. I say that because the position is pretty dependent on the container that your view object is going to be added to.
Although it is just my personal opinion and I am looking forward to hearing if there is indeed a way to do that.
You (effectively) said the view is managed by a view controller. Before you can resize the view, you need to change the Size setting in the view controller's Simulated Metrics to "Freeform". (It is probably set to "None" by default.)

How to split an UIView

Ok, let's say we have an UIView (let's call it mainView) with the size of 480*320 (landscape), and I want to create 2 other views, one to display the first half of the mainView and the second will display the second half of the mainView and both of them will be 240*320, how can I do this?
It all depends on what is in the view at the first place.
If you have dynamic content like changing pictures you can just create two images from that with no problem but if you have UIButtons and other subviews then it's a lot of trouble. For instance what to do if a button or any other object lies in the middle of the main view. If you know your object will be position in either of two half's of the main view then you would go about splitting like this. Check all the subviews of the main view, depending on their position assign them to your new left or right view. The tricky part will be with the right view b/c you will have to adjust the x coordinate.
use the code and split it and replace the name by using the field name which present in the IB
..use picker view method

Moving and existing UI on a UIScrollView

I have some xibs with all sorts of text controls (UITextFields, UITextViews). Since the keyboard obscures some of these text controls when text input starts, I followed Apple's guideline for managing content located under the keyboard.
In short, the solution involves moving all interface elements on a UIScrollView. Doing it from Interface Builder I simply add a UIScrollView on the view, make it the size of the view, send it to back and link it's referencing outlet to the file's owner view property.
In IB this all looks fine, and the UI elements appear above the UIScrollView. However when I run the program, the UI elements are nowhere to be found. Their IBOutlets however seem to get initialized so it looks like they are actually constructed. I've tried to set the UIScrollView alpha to 0 to see if they are placed behind it but I still can't find them. New items that are added to the UIScrollView however, seem to work fine.
This leaves me with the not so great option of rebuilding all my xibs where I need to do this change. It kind of looks like an Interface Builder bug to me. What do you guys think?
Well I've found a solution. It goes like this:
Drag a UISCrollView in IB's main window (where we have the File's Owner and First Responder objects).
Rescale it to the size of the initial view
Drag and drop everything from the original view to the scroll view.
Link the scroll view's referencing outlet to the file's owner view property.
Delete the old view from IB's main window.
#MihaiD
use tableview.contentOffset=CGPointMake(x,y);
I don't know if you really need a UIScrollView. See this question on SO it slides the parent view up.

Adding an image to my UIViewController

just a quick question here.
How can I add an image to my UIViewController. Currently, my view controller has a couple labels and a couple buttons, but I have a file line.jpg that I'd like to add to this view controller as well. And I'd like to add it at a specific location (namely, at the center of the screen). How could I (meaning, what is the code?) initialize some object (that encapsulates my image) and then add it to the screen?
Thanks!
Use UIImageView for that.
http://developer.apple.com/iphone/library/documentation/uikit/reference/UIImageView_Class/Reference/Reference.html