I'm trying to add iAd into my project. I'm following this tutorial http://bees4honey.com/blog/tutorial/how-to-add-iad-banner-in-iphoneipad-app/
I just added the iAd.framework package to my project and set it as Weak.
I added #import <iAd/iAd.h> into my .h file but whenever I try to add the ADBannerViewDelegate it doesn't show up in the intellisense, which means it's not accessible to me.
Same thing for ADBannerView class and the delegate methods (in case I add the delegate anyway).
Any ideas?
Restart XCode and set your target to "Device". The framework might not show up on intellisense but should work nevertheless.
Related
I'm quite new to IOS developpement, and I'm facing a problem here that I haven't encountered before. Here's what I have :
I created a project, added some ViewControllers attached to their own classes. But now, I just added a new ViewController in the storyboard. Then I created a new Objective-C class (with is a subclass of UIViewController). The problem is that in IB, I can't link the ViewController to the newly created class, as I simply don't have the class in the list provided by IB (see the image below). My new class is called MapShownViewController, but as you can see on the image, it's not available.
It worked well for all my other classes but not for this one.
Here's the MapShownViewController.h :
#import <UIKit/UIKit.h>
#interface MapShownViewController : UIViewController
#end
And the MapShownViewController.m :
#import "MapShownViewController.h"
#interface MapShownViewController ()
#end
#implementation MapShownViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)viewDidUnload
{
[super viewDidUnload];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
#end
Can someone explain me what I made wrong please ?
I had this exact problem and it drove me mad. I first noticed it after upgrading XCode to 4.4 from 4.1. I had an existing project that I had been working on in the older version of XCode, and I continued to work on it in 4.4. I did exactly what you did and created a new View in the story board and then created the sub-class files, but the class just was not avaiable in the Custom Class dropdown in IB. After much Googling and frustration I resorted to Quit Xcode (complete quit, not just close) and then re-start it. Then as if by magic it all started working and the new class was immediatley available in the IB custom class dropdown.
Ran into the same issue and restarting XCode was no help. You can always right click the storyboard and select Open As > Source Code. Find your view controller element in the XML file and add a customClass attribute:
<viewController title="Login" id="TJH-Bg-q4u" customClass="XYZLoginViewController" sceneMemberID="viewController">
...
</viewController>
Manual override FTW :).
Check your project settings. xcode->targets->build phases->compile sources
your viewcontroller's implemantation file must be added to this list.
For this to work you have to make sure of the following:
1) The element added to the storyboard is an UIViewController
2) The class you defined has the UIViewController as its superclass
#interface MapShownViewController : UIViewController
3) The Class is being correctly built in the project.
I've been running into this issue and tried all other solutions posted here.
The thing that worked for me was to set the correct super class after creating a custom class. Then you should be able to find and select it from the class dropdown.
e.g.
class LabsViewController: UITableViewController {
Check if you did choose the correct super class in your new class. Sometimes you create a view controller inherited by a UITableVIewController. This one can't be applied to a ViewController pattern in the Storyboard.
I had to set my custom class which inherit from UIViewController and act as table view controller to UITableViewController. I made simple trick and just changed my custom class inheritance to ": UITableViewController" and then i can set this class freely to controller. Of course after it was set i changed inheritance back.
I had the same issue with Xcode 7.1.1 on a Mac OSX app. I tried all the suggestions from the other answers – no success.
Finally I deleted my view controller files and created brand new ones.
Then it suddenly worked...
Just adding another possible solution that helped solve my problem since the others didn't.
I noticed that searching for my custom View Controller file using Command+Shift+O it was being found, but I couldn't see in which folder the file was, so I noticed that for some reason my custom class was missing from the project but still being found in the search.
All I had to do was to move the files to the project again and Voila!
Hope this can help someone in the future.
I'm using Xcode 4.4 and I'm trying to connect the .h and .m files to the view controller in my storyboard but the options I have for adding files are:
Objective-C class
Objective-C category
Objective-C class extension
Objective-C protocol
Objective-C test case class
Every tutorial and answer I have found is for the 4.2 version which goes the option of Objective-C subclass which I don't have. I was wondering if anyone knew how to do it in 4.4.
Thanks
I had the same problem and just found the answer.
First, make sure to read Xcode help about storyboard (in help menu, type story...)
Second, Make sure XCode show you his full interface (in the tool bar, select all three view icons, or at least the bottom right and bottom left icon.
There is a video in the help which explain how to do so.
why you have to connect .m and .h to the view controller ?
try the easy way: file - new file - objective c class and in the second windows check "with XIB interface".
with this, you'll get .m .h and .xib !
I want to use the following transition cross dissolve, but I do not want it to appear flicker when Transition
I apologize I have weak English language
You need to add a subclass to your project:
Add a new .h and .m file as a subclass of UIStoryboardSegue
Add this code to your .m file:
- (void)perform {
[self.sourceViewController presentModalViewController:self.destinationViewController
animated:NO];
}
Now go to your .storyboard and add the name of your .m file to the
class field of your prefered segue.
I can't find the storyboard's segue's class field in XCode 4.4.1. Is it possible that the field was in previous versions but not in the current?
EDIT: I found the way. You must select 'custom' when creating the segue and it works.
Thanks.
BTW: The tutorial is not available.
I am working on the ZBarReader and getting an error
Unknown class ZBarReaderView in Interface Builder file
[UIView setReaderDelegate:]: unrecognized selector sent to instance
0x6859f20
Please look at an attached image at here or below so that you can picture what I am doing so far :-
In the storyboard, I do have a view and its custom class is ZBarReadView. I also wire it with IBOutlet in header file. In m file, I do
viewReader.readerDelegate = self;
and the error is shown after right after that.
Can anybody please point out what I have screwed up....
I found the solution in a thread over here
You need to add the following code in your applicationDidLaunch in your AppDelegate:
// force view class to load so it may be referenced directly from NIB
[ZBarReaderView class];
Should be running fine after that.
you can also try to download 64bits ZbarSDK.
I think the solution should be to add -ObjC flag to "Other Linker Flags" section in your Build Settings. If you can't do this, e.g. you are using Parse Framework that doesn't allow you to set this flag, you will probably have to use the provided solution of Morothat: Set in your AppDelegate the following:
[YOURCLASSNAME class];
It looks like you actually added a view in interface builder and tried to call it a ZbarReaderView for IB to hook up. Correct me if I'm wrong but in this instance I don't think Ib is going to know what you mean by ZBarReaderView.
I'm Also assuming you haven't actually implemented the delegate method in your .m file.
I have an XCode project I am working on that has multiple views controlled by a tabBar that is throwing multiple instances of the error:
"cannot find interface declaration for '~my sub view name~', superclass of '~my sub view name~'
These sub views were created after the original project as new files. Each has a line of code like this:
#interface meViewAndEdit : meViewAndEdit
I see no #import statements either. The project fails to build and I am not sure what i should be setting these to. Should I be referencing my App delegate as the superclass? what is missing here?
UPDATE: (updated)
I changed the interface statements for each of my header files for the views i created as follows
#interface friends : UIView
BUT, it seems that i have a new issue that i'll have to research:
"UIView" may not response to "initWithNibName.bundle"
This is now present in each of the .m files for the views I created.
still learning, thanks in advance for your input.
When declaring a class in Objective-C, you need to specify the class name, as well as the superclass. In your code #interface meViewAndEdit : meViewAndEdit, you are essentially declaring a class that is a subclass of itself. Since you are trying to create a subclass of UIView, the class declaration should look as follows: #interface meViewAndEdit : UIView.
Also, in a comment in another answer, you asked whether or not you need to #import the app delegate in every class. The answer to this is usually no, unless you specifically need to access something involving your specific app delegate class.
I will also make note that it is conventional to give classes a capitalized name. For example, it should be MeViewAndEdit, rather than meViewAndEdit. You only should keep the first letter lowercase if it is the name of a variable or function.
EDIT: The reason that you are encountering the errors in your update is that you are trying to subclass UIViewController, not UIView. On top of this, instead of subclassing either one, you are subclassing the app delegate. Change your line of code #interface subviewname : my_app_delegate to #interface subviewname : UIViewController. You are trying to create a subclass of UIViewController, not my_app_delegate.
On another conventional note, it is never good to put underscores in a class name. Always name classes in camel case like MyAppDelegate, not my_app_delegate.
You need to #include the .h header files in all classes in which you are using them.