Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have twoo buttons underneath the view controller. One of those buttons makes calculations. The second one shows information about these calculations. For the information I' m using a modal segue to another viewcontroller called werkwijzeViewController. The calculations button doesn't pose problems. On pressing the information button I get "UIStoryboardModalSegue popoverController]: unrecognized selector sent to instance". What's wrong? I'm uploading some of the relevant code:
viewcontroller.h
#import <UIKit/UIKit.h>
#import "breuk.h"
#import "verklaringViewController.h"
#interface ViewController : UIViewController <UIPopoverControllerDelegate>
#property (strong, nonatomic) IBOutlet UITextField *tellerVeld1;
#property (strong, nonatomic) IBOutlet UITextField *noemerVeld1;
#property (strong, nonatomic) IBOutlet UILabel *quotientVeld;
#property (strong, nonatomic) IBOutlet UITextField *tellerVeld2;
#property (strong, nonatomic) IBOutlet UITextField *noemerVeld2;
#property (strong, nonatomic) IBOutlet UIButton *berekenKnop;
#property (strong, nonatomic) breuk *breuk1;
#property (strong, nonatomic) breuk *breuk2;
#property (strong, nonatomic) breuk *hoofdbreuk;
#property (strong, nonatomic) IBOutlet UITextField *uitkomstNoemerVeld;
#property (strong, nonatomic) IBOutlet UITextField *uitkomstTellerVeld;
#property (strong, nonatomic) IBOutlet UILabel *uitkomstStreep;
#property (strong, nonatomic) UIPopoverController *popoverController;
- (IBAction)berekenQuotient:(id)sender;
#end
viewcontroller.m
#import "ViewController.h"
#interface ViewController ()
{
BOOL veldVerplaatst;
}
#end
#implementation ViewController
#synthesize tellerVeld1;
#synthesize noemerVeld1;
#synthesize quotientVeld;
#synthesize tellerVeld2;
#synthesize noemerVeld2;
#synthesize berekenKnop;
#synthesize uitkomstNoemerVeld;
#synthesize uitkomstTellerVeld;
#synthesize uitkomstStreep;
#synthesize breuk1;
#synthesize breuk2;
#synthesize hoofdbreuk;
#synthesize popoverController;
...
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
UIStoryboardPopoverSegue *popoverSegue;
popoverSegue=(UIStoryboardPopoverSegue *)segue;
UIPopoverController *popoverController;
popoverController = popoverSegue.popoverController;
popoverController.delegate = self;
verklaringViewController *verklaringVC;
verklaringVC=(verklaringViewController *)popoverController.contentViewController;
...
}
#end
werkwijzeViewController.h
#import <UIKit/UIKit.h>
#import "ViewController.h"
#interface werkwijzeViewController : UIViewController
#property (strong, nonatomic) IBOutlet UIButton *af;
#property (strong, nonatomic) IBOutlet UITextView *vereenvoudigBreuken;
#property (strong, nonatomic) IBOutlet UITextView *vermenigvuldigBreuken;
#property (strong, nonatomic) NSMutableArray *tabelTellerOntbonden;
#property (strong, nonatomic) NSMutableArray *tabelNoemerOntbonden;
#property (strong, nonatomic) NSMutableArray *tabelGgdOntbonden;
#end
werkwijzeViewController.m
#import "werkwijzeViewController.h"
#interface werkwijzeViewController ()
#end
#implementation werkwijzeViewController
#synthesize tabelGgdOntbonden;
#synthesize tabelNoemerOntbonden;
#synthesize tabelTellerOntbonden;
...
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
tabelTellerOntbonden =[NSMutableArray new];
tabelTellerOntbonden = [((ViewController *)self.presentingViewController).breuk1 ontbindInFactoren:((ViewController *)self.presentingViewController).breuk1.tellerBreuk inTabel:tabelTellerOntbonden];
NSLog(#"%#",tabelTellerOntbonden);
}
#end
breuk.m
#import "breuk.h"
#implementation breuk
#synthesize tellerBreuk;
#synthesize noemerBreuk;
#synthesize origineleNoemerBreuk;
#synthesize origineleTellerBreuk;
#synthesize ggd;
#synthesize quotientBreuk;
...
- (NSMutableArray *)ontbindInFactoren:(int)product inTabel:(NSMutableArray *)tabel
{
for (int priemfactor=1; priemfactor<=product; priemfactor++)
{
while (product%priemfactor==0)
{
[tabel addObject:[NSString stringWithFormat:#"%i",priemfactor]];
}
}
return tabel;
}
#end
You should post the code for all of your IBAction methods tied to your two buttons.
As a glance, it looks to me like the problem is that your prepareForSegue method blindly casts your segue to type UIStoryboardPopoverSegue, and then tries to access the segue's popoverController property.
Your prepareForSegue method will be called for every segue. You need code in your prepareForSegue that checks the segue identifier to make sure you are dealing wit the correct segue before casting it to a UIStoryboardPopoverSegue.
Related
these 2 are the files where i m creating a protocol and then declare the delegate in another class
this is my favouriteViewController.h
#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>
#import "ViewController.h"
#class FavouritesTableViewController;
#protocol FavouritesTableViewControllerDelegate<NSObject>
- (void)senDetailsViewController:(FavouritesTableViewController *)controller didFinishEnteringItem:(NSArray *)item;
#end
#interface FavouritesTableViewController : UITableViewController <UISearchControllerDelegate,UISearchBarDelegate>
#property (strong, nonatomic) IBOutlet UISearchController *search;
#property (strong, nonatomic) IBOutlet UITableView *table;
#property (nonatomic, weak) id < FavouritesTableViewControllerDelegate > delegate;
#end
and this is my viewController.h
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#import "FavouritesTableViewController.h"
#interface ViewController : UIViewController <CLLocationManagerDelegate,FavouritesTableViewControllerDelegate>
#property (weak, nonatomic) IBOutlet UIImageView *weatherIcon;
#property (weak, nonatomic) IBOutlet UILabel *Place;
#property (weak, nonatomic) IBOutlet UILabel *Temperature;
#property (weak, nonatomic) IBOutlet UILabel *unit;
#property (weak, nonatomic) IBOutlet UILabel *weatherText;
#property (weak, nonatomic) IBOutlet UITextView *Info;
#property (weak, nonatomic) IBOutlet UILabel *summary;
#property (strong,nonatomic) NSString *longitude;
#property (strong,nonatomic) NSString *latitude;
#property (strong,nonatomic) NSString *locationName;
#property BOOL setLocation;
#property (weak, nonatomic) IBOutlet UIScrollView *scroll;
- (IBAction)forecast:(UIButton *)sender;
- (IBAction)Share:(UIButton *)sender;
- (IBAction)history:(UIButton *)sender;
#property (weak, nonatomic) IBOutlet UIActivityIndicatorView *activIndicator;
- (IBAction)favbutton:(id)sender;
#end
the error i get is
:- Cannot find protocol declaration for
'FavouritesTableViewControllerDelegate'
I'm declaring these methods and protocols to pass data from FavouriteViewController to ViewController
and this is the protocol method which i call in ViewController.m
-(void)senDetailsViewController:(FavouritesTableViewController *)controller didFinishEnteringItem:(NSArray *)item
{
controller.delegate = self;
self.latitude = [item[0] valueForKey:#"lat"];
self.longitude = [item[0] valueForKey:#"long"];
self.locationName = [item[0] valueForKey:#"name"];
self.setLocation = YES;
[self viewDidLoad];
}
Ths is happening because of recursive import, in FavouritesTableViewController you are importing "ViewController.h" and again ViewController.h you are importing "FavouritesTableViewController.h"
try
#class viewController;
#class FavouritesTableViewController;
in FavouritesTableViewController.h and remove "#import ViewController.h"
I have a view controller HomeController & BookController.I am going from view controller HomeController to BookController.I am passing data back to previous view controller.So i have used this approach.
#import <UIKit/UIKit.h>
#import "BaseController.h"
#import <MediaPlayer/MediaPlayer.h>
#protocol HomeProtocol
- (void)setComment:(BOOL)data;
-(void)setCommnetArray:(NSMutableArray*)data;
#end
#protocol BookProtocol
-(void)setBook:(BOOL)status;
#end
#interface HomeViewController : BaseController<UITableViewDataSource,UITableViewDelegate,HomeProtocol,UIScrollViewDelegate,BookProtocol,UINavigationControllerDelegate>
#property (weak, nonatomic) IBOutlet UITableView *table_view;
#property BOOL hasUserPostedComment;
#property NSInteger commentIndex;
#property (weak, nonatomic) IBOutlet UILabel *label_post_status;
#property UIRefreshControl *refreshControl;
#property NSInteger start_offset;
#property NSInteger end_offset;
#property (weak, nonatomic) IBOutlet UIButton *btn_refresh;
#property NSMutableArray *temp_user_cooments;
#property MPMoviePlayerController *moviePlayerController;
#property BOOL isBookMarkLoaded;
#end
BookMarkController.h
#import <UIKit/UIKit.h>
#import "BaseController.h"
#import "HomeViewController.h"
#import <MediaPlayer/MediaPlayer.h>
#protocol HomeProtocol
- (void)setComment:(BOOL)data;
-(void)setCommnetArray:(NSMutableArray*)data;
#end
#interface BookMarkController : BaseController<UITableViewDataSource,UITableViewDelegate,HomeProtocol,UIScrollViewDelegate>
#property (nonatomic, weak) id<BookProtocol> myDelegate;
#property (weak, nonatomic) IBOutlet UITableView *table_view;
#property BOOL hasUserPostedComment;
#property NSInteger commentIndex;
#property (weak, nonatomic) IBOutlet UILabel *label_post_status;
#property UIRefreshControl *refreshControl;
#property NSInteger start_offset;
#property NSInteger end_offset;
#property (weak, nonatomic) IBOutlet UIButton *btn_refresh;
#property NSMutableArray *temp_user_cooments;
#property MPMoviePlayerController *moviePlayerController;
#property NSString *index;
#end
Method implementation
-(void)setBook
{
NSLog(#"set book called");
self.isBookMarkLoaded=true;
}
It gives error Unrecognized selector sent to instance.Please tell me what is the issue here.
#protocol BookProtocol
-(void)setBook:(BOOL)status;
#end
Add above protocol to BookMarkController.h. Create delegate of the same in BookMarkController.h file. Make a call to -(void)setBook:(BOOL)status; from BookMarkController.m file
Add delegate in HomeViewController.h file. Define -(void)setBook:(BOOL)status; in HomeViewController.m file and also assign delegate to self.
That's all.
I want to send the information from Players View Controller to Current Match View Controller using a delegate. The only thing is that PlayersViewCotroller and GameDetailsViewController are seperated by another view controller. What should I do to make sure that the selector is being called? Am I missing anything?
#import <UIKit/UIKit.h>
#class PlayersViewController;
#protocol PlayersViewControllerDelegate <NSObject>
- (void)addItemViewController:(PlayersViewController *)controller didFinishEnteringPlayer1:(NSString *)player1 didFinishEnteringPlayer2:(NSString *)player2;
#end
#interface PlayersViewController : UIViewController
#property (weak, nonatomic) IBOutlet UITextField *player1;
#property (weak, nonatomic) IBOutlet UITextField *notes1;
#property (weak, nonatomic) IBOutlet UITextField *player2;
#property (weak, nonatomic) IBOutlet UITextField *notes2;
#property (weak, nonatomic) IBOutlet UIBarButtonItem *nextButton;
- (IBAction)nextButtonPressed:(id)sender;
#property (nonatomic, weak) id <PlayersViewControllerDelegate> pdelegate;
#end
PlayersViewController.m
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqual:#"playersSegue"]) {
if([self.pdelegate respondsToSelector:#selector(addItemViewController:didFinishEnteringPlayer1:didFinishEnteringPlayer2:)]){
[self.pdelegate addItemViewController:self didFinishEnteringPlayer1: player1.text didFinishEnteringPlayer2: player2.text];
NSLog(#"Works");
}
}
CurrentMatchViewController.m (sending the info to this view controller)
- (void)addItemViewController:(PlayersViewController *)controller didFinishEnteringPlayer1:(NSString *)player1 didFinishEnteringPlayer2:(NSString *)player2 {
NSLog(#"%#", player1);
}
So I have this -
#import <UIKit/UIKit.h>
#import "RateView.h"
#interface BasicCardViewController : UIViewController<RateViewDelegate>
#property (weak, nonatomic) IBOutlet UILabel *label;
#property(copy, nonatomic)NSString *message;
#property(atomic)NSInteger rating;
#property (strong, nonatomic) IBOutlet RateView *rateView;
#property (weak, nonatomic) IBOutlet UILabel *ratingLabel;
#end
and this - in my RateView.h file.
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
#class RateView;
#protocol RateViewDelegate
-(void)rateView:(RateView *)rateView ratingDidChange:(float)rating;
#end
#interface RateView : UIView
#property(strong,nonatomic)UIImage* fullSelectedStar;
#property(strong,nonatomic)UIImage* notSelectedStar;
#property(strong, nonatomic)UIImage* halfSelectedStar;
#property (assign, nonatomic)float rating;
#property(assign) BOOL editable;
#property (strong) NSMutableArray* imageViews;
#property(assign,nonatomic) int maxRating;
#property(assign) int midMargin;
#property(assign)int leftMargin;
#property (assign) CGSize minImageSize;
#property (assign) id <RateViewDelegate> delegate;
#end
But I get two errors -
1.Cannot find protocol declaration for 'TooviaRateViewDelegate'
2.Unknown type name "RateView"
I've tried to clean, and I've verified that the files are where they should be (their filepaths are to the project).
Why is this happening?
Edit - my AppDelegate.h
#import <UIKit/UIKit.h>
#import "SearchViewController.h"
#interface TooviaAppDelegate : UIResponder <UIApplicationDelegate>
#property (strong, nonatomic) UIWindow *window;
#property NSOperationQueue *queue;
#property (strong, nonatomic) NSDictionary *userProfile;
#property (strong, nonatomic) SearchViewController *searchViewController;
- (NSOperationQueue*) getOperationQueue;
- (id)getSettings:(NSString *)keyPath;
- (void) saveCookies;
#end
There are also issues in my SearchViewController
#import <UIKit/UIKit.h>
#import "BasicCardViewController.h"
#interface SearchViewController : UIViewController
<UISearchBarDelegate, UISearchDisplayDelegate, UITableViewDataSource, UITableViewDelegate>
- (IBAction)searchButtonClicked:(UIButton *)sender;
- (IBAction)backgroundTap:(id)sender;
#property (weak, nonatomic) IBOutlet UITableView *resultTable;
#property (weak, nonatomic) IBOutlet UITextField *searchBar;
#property (strong, nonatomic) NSArray *resultsTuples;
#property (weak, nonatomic) IBOutlet UIButton *searchButton;
#property (copy, nonatomic) NSArray *controllers;
#property(strong,nonatomic)BasicCardViewController *detailController;
Delegate and data source properties are usually marked as weak for the object graph management reasons described earlier, in “Avoid Strong Reference Cycles.”
I recently changed the view of my school project's application from a UITableView to a UIView and added custom uibuttons in interface builder along with their properties and linked them appropriately to the file owner. For some reason, when I launch the application, the table view cuts off where I placed the buttons and is a blank white region. Any ideas what I could have done wrong? Some of the interface and implementation code is below. I'm newer to xcode so be keep that in mind.
.h:
#class EditstudentViewController;
//#interface StudentList : EmbeddedTableView : UIViewController <UITableViewDelegate, UITableViewDataSource> {
#interface StudentList: UIViewController <UITableViewDelegate, UITableViewDataSource> {
NSMutableArray *_students;
int indexTag;
EditstudentViewController *_editstudentViewController;
//UINavigationController *navigationController;
IBOutlet UITableView *tableView;
IBOutlet UIButton *roleCall;
IBOutlet UIButton *groups;
IBOutlet UIButton *options;
IBOutlet UIButton *classStats;
}
#property (retain) NSMutableArray *students;
#property (retain) EditstudentViewController *editstudentViewController;
- (IBAction)back:(id)sender;
#property (nonatomic, retain) UITableView *tableView;
#property (nonatomic, retain) UIView *roleCall;
-(IBAction)roleCall:(id)sender;
#property (nonatomic, retain) UIView *groups;
-(IBAction)groups:(id)sender;
#property (nonatomic, retain) UIView *options;
-(IBAction)options:(id)sender;
#property (nonatomic, retain) UIView *classStats;
-(IBAction)classStats:(id)sender;
.m:
#implementation StudentList;
#synthesize students = _students;
#synthesize editstudentViewController = _editstudentViewController;
#synthesize tableView;
#synthesize roleCall;
#synthesize groups;
#synthesize options;
#synthesize classStats;