This code :
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <MessageUI/MessageUI.h>
#import "MessageComposerViewController.h"
#import <MessageUI/MFMailComposeViewController.h>
#interface MapViewController : UIViewController <MFMailComposeViewControllerDelegate> // Add the delegate
- (IBAction)showEmail:(id)sender;
{
IBOutlet MKMapView *mapView;
}
#property (nonatomic, retain) MKMapView *mapView;
#end
This problem or error :
Cannot find protocol declaration for 'MFMailComposeViewControllerDelegate'; did you mean 'UIPageViewControllerDelegate'?
for this lign : #import "MessageComposerViewController.h"
Expected identifier or '('
for this lign : #interface MapViewController : UIViewController // Add the delegate
and this lign : {
Thanks for advance. :)
Try This,
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <MessageUI/MessageUI.h>
#import "MessageComposerViewController.h"
#import <MessageUI/MFMailComposeViewController.h>
#interface MapViewController : UIViewController <MFMailComposeViewControllerDelegate,UINavigationControllerDelegate> {
IBOutlet MKMapView *mapView;
}
- (IBAction)showEmail:(id)sender;
#property (nonatomic, retain) MKMapView *mapView;
#end
If you do the above and still see the warning in Xcode, try building or building & running your app. Sometimes these warnings linger after you've addressed the problem and are cleared out by a compilation cycle.
I encountered the same problem today coding an app for ios8.
First thing that I did was re-add the framework, but it didn't help. The problem was I ignored libAWDProtobufFacetimeiMessage - a protocol buffer file. I'm no professional to guess why, but when I added both buffer and the framework itself, the error message disappeared. I have posted a screenshot here. Hope my answer helps anyone looking here in the future.
Related
I am trying to figure out how to take the delegate in LocationViewController and SetScoringTableViewController and implement both of them in GameDetailsTableViewController. LocationViewControllerDelegate was already working, but when I added the new SetScoringTableViewController, the program had an error.
LocationViewController.h
#import "ViewController.h"
#class LocationViewController;
#protocol LocationViewControllerDelegate <NSObject>
- (void)addItemViewController:(LocationViewController *)controller didFinishEnteringItem:(NSString *)name;
#end
#interface LocationViewController : UIViewController
#property (nonatomic, weak) id <LocationViewControllerDelegate> delegate;
#end
SetScoringTableViewController.h
#import <UIKit/UIKit.h>
#import "GameDetailsTableViewController.h"
#import "LocationViewController.h"
#class SetScoringTableViewController;
#protocol SetScoringTableViewControllerDelegate <NSObject>
- (void)addItemViewControllerSS:(SetScoringTableViewController *)SScontroller didFinishEnteringItemSS:(NSString *)SSname;
#end
#interface SetScoringTableViewController : UITableViewController
#property (nonatomic, strong) id <SetScoringTableViewControllerDelegate> SSdelegate;
#end
GameDetailsTableViewController.h
#import <UIKit/UIKit.h>
#import "LocationViewController.h"
#import "SetScoringTableViewController.h"
#interface MainViewController : UITableViewController <LocationViewControllerDelegate, SetScoringTableViewControllerDelegate>
When I run this I get an error: "Cannot find protocol declaration for 'SetScoringTableViewControllerDelegate' even though I have.
The only way I have found to fix this problem is to put the "SetScoringTableViewController delegate in the LocationView Controller, but I know that is not right. Any help would be greatly appreciated.
You have a dependency loop:
SetScoringTableViewController.h
#import "GameDetailsTableViewController.h"
GameDetailsTableViewController.h
#import "SetScoringTableViewController.h"
But it looks like you can remove the #import "GameDetailsTableViewController.h" as there is no mention of it in the header file.
What you're experiencing is an an #import cycle. To break the import loop
remove this import line:
#import "GameDetailsTableViewController.h"
from SetScoringTableViewController.h and put it in a .m file.
Try to separate the delegate on a different .h file.
At the last line, I got the error: Duplicate interface definition for class "ViewController". I want to do an IBAction. What is the fault? What can I do? Please help me.
//
// ViewController.h
#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>
#interface SimpleEmailViewController : UIViewController <MFMailComposeViewControllerDelegate>
- (IBAction)showEmail:(id)sender;
#end
#interface ViewController : UIViewController <MFMessageComposeViewControllerDelegate> {
}
-(IBAction)sendMessage:(id)sender;
- (IBAction)showEmail:(id)sender;
#property (nonatomic, strong) IBOutlet UIWebView *site ;
- (IBAction)call:(id)sender;
#property (retain, nonatomic) IBOutlet UIButton *myBotton;
#end
#interface ViewController : UIViewController**i**
The problem is exactly what the error states. You defined #interface viewController twice. Change the name of one to something else. As a side note, it is a terrible idea to name something with a name apple has already used. You should change both viewControllers to something else, more descriptive of what it does, like mailViewController or setupViewController. Weird stuff can happen when you use apple defined names.
#interface FSMainiPadViewController : UIViewController
Why don't you just make it simple like this?
// ViewController.h
#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>
#interface ViewController : UIViewController <MFMailComposeViewControllerDelegate, MFMessageComposeViewControllerDelegate>
// Actions
- (IBAction)showEmail:(id)sender;
- (IBAction)sendMessage:(id)sender;
- (IBAction)call:(id)sender;
// Properties
#property (nonatomic, strong) IBOutlet UIWebView *site;
#property (retain, nonatomic) IBOutlet UIButton *myBotton;
#end
I am not sure what is causing this problem, but I now cannot create outlets. When I create an outlet it appears and works fine in code, but does not appear under the view controller in storyboard. Old outlets have a warning symbol on them like this
When I remove this outlet, its gone and does not appear back to connect. I am running Xcode beta 6.2 because moving to 6.2 temporarily fixed this problem because I was having it beforehand in 6.1.
Here is the .h file of this class
#import <UIKit/UIKit.h>
#interface DashboardViewController : UITableViewController {
NSString *currentDay;
}
#property (nonatomic, weak) IBOutlet UILabel *dayLabel;
#property (nonatomic, weak) IBOutlet UILabel *blockLabel;
#property (nonatomic, weak) IBOutlet UILabel *currentClassLabel;
#end
and here are the outlets listed in storyboard
These are the details of the warning, but this is .h file's code for this class
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#interface InfoViewController : UIViewController {
IBOutlet UIScrollView *AISScrollView;
IBOutlet MKMapView *AISMapView;
}
-(IBAction)studentHandbook:(id)sender;
#end
Oddly enough, I ended up finding a solution and that was moving the project out of the directory that it was in. It was in my Dropbox folder and moving it out fixed. If anyone has this problem in the future and also happens to have the proj in their Dropbox, move it out.
try to change this:
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#interface InfoViewController : UIViewController {
IBOutlet UIScrollView *AISScrollView;
IBOutlet MKMapView *AISMapView;
}
-(IBAction)studentHandbook:(id)sender;
#end
to that:
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#interface InfoViewController : UIViewController {
}
#property (nonatomic,weak) IBOutlet UIScrollView *AISScrollView;
#property (nonatomic,weak) IBOutlet MKMapView *AISMapView;
-(IBAction)studentHandbook:(id)sender;
#end
Just in case someone suffers from the same thing again, the best answer inside this other thread did the trick for me:
XCode 6: can't connect any IBOutlet to ViewController
Removing the .h and .m files from the project (their references) and readding them again was the solution that worked for me.
I am trying to declare a property
#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
#interface ViewController : UIViewController
{
#property (nonatomic, strong) MPMoviePlayerController*player;
}
#end
I receive a red warning sign when i click on it, it reads;
a parameter list without types is only allowed in function definition
properties are outside of braces
#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
#interface ViewController : UIViewController
{
// here is for ivars only
id _something;
}
// properties and methods
#property (nonatomic, strong) MPMoviePlayerController*player;
#end
Xcode has showed out of the blue this error: "Unknown type name"
I'll explain:
My StoriesViewController.h:
#import <UIKit/UIKit.h>
#import "Stories.h"
#interface StoriesViewController : UIViewController <UITextViewDelegate>
#property (strong) Stories *story; //Here it goes- "Unknown type name `Stories`"
#property (weak) IBOutlet UITextView *storyView;
#end
In my Stories.h:
#import <UIKit/UIKit.h>
#import "ViewController.h"
#interface Stories : UIDocument
#property (strong) NSString * storyContent;
#end
Again, out of the blue.
Thanks in advance.
EDIT:
In my ViewController.h:
#import <UIKit/UIKit.h>
#import "Stories.h"
#import "StoriesViewController.h"
#import "StoriesPickerViewController.h"
#import <QuartzCore/QuartzCore.h>
#interface ViewController : UIViewController <UITextFieldDelegate, UIAlertViewDelegate> {
}
#end
NB #class throws loads of ARC issues.
I have removed useless references to ViewController.h, worked.
SOLVED!
You have a circular reference problem.
What's happening is that when you load your ViewController it goes through it's imports, it loads Stories.h, it goes to load it's imports and it goes back to ViewController.h, so you are stuck in an infinite loop there.
Either remove one of the conflicting imports, or use forward class declaration (that example is for C++, see here for an example with Objective-C)