Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't ctrl drag Views to header file

Tags:

ios

Hi I'm very new to ios development.

I'm developing a map application where I use mapkit. I have a viewController with the map view and a corresponding viewController class.

Now I would like to manipulate the mapView, and is trying to set up the delegate. BUT i can't ctrl+drag anything (includes the mapView) to my header-file. So what do I do then??

I've tried to write the auto implemented stuff in my header-file but this isn't working either :(

Any help is really appreciated..

Here's my header-file:

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>

#define METERS_PER_MILE 1609.344

@interface MapViewController : UIViewController<MKMapViewDelegate> {

}

@property (weak, nonatomic) IBOutlet MKMapView *mapView;

@end

And a note to ios developers what the hell is this drag and drop doing in a IDE?!?

like image 931
DNRN Avatar asked Feb 20 '23 14:02

DNRN


1 Answers

Here are the steps to create an IBOutlet in XCode:

  1. Click on your xib / Storyboard to edit it in Interface Builder
  2. Bring the view for which you want to create an outlet in front
  3. Make sure that Assistant editor is visible. If not click on this icon: enter image description here
  4. Now you should see your source file next to your UI editor (also make sure that you've set the custom class of your controller in the identity inspector)
  5. Important: Make sure that your editor is not zoomed out. Click on the = button to do so.
  6. Set the assistant mode to 'Automatic' if you don't see your header file and control+drag to your source to create the IBOutlet enter image description here

I hope that this will clarify the whole procedure for you. Note that this is only a convenience. You could manually declare the IBOutlet and connect it to your view as well.

like image 160
Alladinian Avatar answered Mar 07 '23 17:03

Alladinian