I'm quite new to iOS dev, I met this problem while i'm trying to embed an open source Wheel Rotating project (https://github.com/funkyboy/How-To-Create-a-Rotating-Wheel-Control-with-UIKit) into mine.
Basically, I copied the relevant code files and assets from this open source project into mine, and did some necessary changes, hope it will run.
The "Rotary Wheel Component" were from the original opensource project, and the "Mood Roulette" is my project.
Here's the screen shot of the project's structure:
And the stacktrace:
2014-03-10 13:06:12.865 Mood Roulette[13125:60b] cl is 7 | 0.392699, 0.785398, 1.178097
2014-03-10 13:06:12.866 Mood Roulette[13125:60b] -[UCViewController wheelDidChangeValue:]: unrecognized selector sent to instance 0x146d175f0
2014-03-10 13:06:12.869 Mood Roulette[13125:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UCViewController wheelDidChangeValue:]: unrecognized selector sent to instance 0x146d175f0'
*** First throw call stack:
(0x18ba1f09c 0x19799dd78 0x18ba23d14 0x18ba21a7c 0x18b9414ac 0x1000c05fc 0x1000bfb44 0x1000c26f4 0x18e8f42c0 0x18e8f4044 0x18e8fb7dc 0x18e8f8ab0 0x18e96c88c 0x18e9691f0 0x18e9629a0 0x18e8f5530 0x18e8f4720 0x18e9620b0 0x191345128 0x191344c54 0x18b9defc8 0x18b9def28 0x18b9dd14c 0x18b91db38 0x18e9612d4 0x18e95c0e8 0x1000c24b8 0x197f87aa0)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
======
The error point is on the line 100
[self.delegate wheelDidChangeValue:[self getCloveName:currentValue]];
of the code:
https://github.com/funkyboy/How-To-Create-a-Rotating-Wheel-Control-with-UIKit/blob/master/RotaryWheelProject/SMRotaryWheel.m
Here's the part I've changed (Mainly the changes were made in ViewControllers):
UCAppDelegate.h:
#import <UIKit/UIKit.h>
//#class UCViewController;
#interface UCAppDelegate : UIResponder <UIApplicationDelegate>
#property (strong, nonatomic) UIWindow *window;
//#property (strong, nonatomic) UCViewController *viewController;
#end
UCAppDelegate.m:
#implementation UCAppDelegate
//#synthesize window;
//#synthesize viewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// self.window.rootViewController = self.viewController;
// [self.window makeKeyAndVisible];
return YES;
}
UCViewController.h
#import <UIKit/UIKit.h>
#import "SMRotaryProtocol.h"
#interface UCViewController : UIViewController
#property (nonatomic, strong) UILabel *valueLabel;
#end
UCViewController.m:
#import "UCViewController.h"
#import "SMRotaryWheel.h"
#interface UCViewController ()
#end
#implementation UCViewController
#synthesize valueLabel;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
valueLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 350, 120, 30)];
valueLabel.textAlignment = NSTextAlignmentCenter;
valueLabel.backgroundColor = [UIColor lightGrayColor];
[self.view addSubview:valueLabel];
SMRotaryWheel *wheel = [[SMRotaryWheel alloc] initWithFrame:CGRectMake(0, 0, 200, 200)
andDelegate:self
withSections:8];
wheel.center = CGPointMake(160, 240);
[self.view addSubview:wheel];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#end
The project will build without any problems, but will leave a black screen and give a unrecognised selector error while running.
Is there anything I also need to change?
Thanks for any help.
You don't have an actual implementation of the method wheelDidChangeValue: in your UCViewController, from what you've posted. So, when that method is called at runtime, there's no method to "catch" the call, which causes the error you're seeing.
I think you have to set the delegate of the SMRotaryWheel class:
#import <UIKit/UIKit.h>
#import "SMRotaryProtocol.h"
#interface UCViewController : UIViewController <SMRotryWheelDelegate>
#property (nonatomic, strong) UILabel *valueLabel;
#end
ATTENTION: I actually don't know how the Delegate is called
And then don't forget to implement the delegate methods.
Related
I have a view controller on the StoryBoard with my custom class. Here the code:
BGMDatePickerViewController.h
#import <UIKit/UIKit.h>
//declare a protocol with name
#protocol DatePickerViewControllerDelegate //declare a delegate so that this class can notify another class when a user selects a chart
//protocol methods
//- (void)userDataChangedWithUsername;
#end
//declare a class with inheritance
#interface BGMDatePickerViewController : UIViewController <UIPickerViewDelegate, UIPickerViewDataSource, UITextFieldDelegate>
//create a public property
#property (weak, nonatomic) id<DatePickerViewControllerDelegate> delegate; //property to store the delegate
#end
I would like to show this ViewController on another one with delegate. Here the code:
BGMChartViewController.h
#import <UIKit/UIKit.h>
#import "BGMDatePickerViewController.h"
//declare a class with inheritance
#interface BGMChartViewController : UIViewController <UIActionSheetDelegate, DatePickerViewControllerDelegate> //conforms UIActionSheetDelegate and my custom DatePickerViewControllerDelegate protocols
//create a public IB methods
- (IBAction)showDateEntryForm:(id)sender;
#end
BGMChartViewController.m
#import "BGMChartViewController.h"
#interface BGMChartViewController ()
//create a private properties
#property (strong, nonatomic) UIPopoverController *datePickerPopover;
#end
#implementation BGMChartViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:NO];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (IBAction)showDateEntryForm:(id)sender
{
DDLogVerbose(#"%s: has been started...", __FUNCTION__);
BGMDatePickerViewController *datePickerVC = [self.storyboard instantiateViewControllerWithIdentifier:#"dateEntryFormVC"];
datePickerVC.delegate = self; //HERE THE FALL!!!!!
self.datePickerPopover = [[UIPopoverController alloc] initWithContentViewController:datePickerVC];
//define the popover size
self.datePickerPopover.popoverContentSize = CGSizeMake(320.0, 400.0);
//let’s display it
[self.datePickerPopover presentPopoverFromRect:[(UIButton *)sender frame]
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
}
#end
On the line which I marked it just fall with:
-[BGMDatePickerViewController setDelegate:]: unrecognized selector sent to instance 0x78a3bcf0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[BGMDatePickerViewController setDelegate:]: unrecognized selector sent to instance 0x78a3bcf0'
If I comment this problem line it's ok I see my custom view controller so that means that I am ok with instantiateViewControllerWithIdentifier tag...
I don't understand what do I do wrong?
Modify to the below line and check:-
#protocol DatePickerViewControllerDelegate<NSObject>
First of all, let me give you a heads-up. I'm moderately familiar with XCode (5) and Objective-C.
But, consider me a noob and please help me out.
I'm trying to build an app. I need a Slide out menu in all Views of the app.
I made a dummy project using SwRevealViewController Class. And I have made two slide out menus also. And it works.
I tried to use the same method in the App that I'm building.
But my build has failed with no Errors and a single warning, which I had in my previous dummy project....
I have already imported SwRevealViewController.h to AppDelegate.m and ViewController.m
I'm trying to use a TableViewController as slideout menu (which is empty, I haven't added any code to it yet). But the build is failing.
Edit:
" The error is as follows..
"#synthesize of 'weak' property is only allowed in ARC or GC Mode"
I'm using Core Data with my project. And I have to use webservice extensively in my App. So I have disabled ARC. "
I have also tried replacing table with other views, but the same result. Now I'm stuck.
I know its some thing with my code, but I couldn't find it.
I'm including code of AppDelegate.m and ViewController.m.
Please check it and tell me what is wrong. I'm at a loss here.
Edit:
" I cannot upload images due to Stack Overflow restrictions. So I have uploaded a screenshot of the error in tinypic. Here is the url.
http://tinypic.com/r/162vli/8 "
Thank you for all your help.
AppDelegate.h
// AppDelegate.h
// IndianBloodBank
//
// Created by Roshith Balendran on 8/5/14.
// Copyright (c) 2014 Olympus. All rights reserved.
//
#import <UIKit/UIKit.h>
#class SWRevealViewController;
#interface AppDelegate : UIResponder <UIApplicationDelegate>
#property (strong, nonatomic) UIWindow *window;
#property (strong, nonatomic) UINavigationController *UINV;
#property (strong, nonatomic) SWRevealViewController *splitMenu;
#property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
#property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
#property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
- (void)saveContext;
- (NSURL *)applicationDocumentsDirectory;
#end
AppDelegate.m
//
// AppDelegate.m
// IndianBloodBank
//
// Created by Roshith Balendran on 8/5/14.
// Copyright (c) 2014 Olympus. All rights reserved.
//
#import "AppDelegate.h"
#import "SWRevealViewController.h"
#import "HomePageViewController.h"
#import "SlideOutMenuTableViewController.h"
#import "SearchViewController.h"
#import "AboutUsViewController.h"
#import "SponsorsViewController.h"
#import "HowToDonateViewController.h"
#import "EmergencyViewController.h"
#implementation AppDelegate
#synthesize splitMenu,window,UINV;
#synthesize managedObjectContext = _managedObjectContext;
#synthesize managedObjectModel = _managedObjectModel;
#synthesize persistentStoreCoordinator = _persistentStoreCoordinator;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window = window;
HomePageViewController *HPVC = [[HomePageViewController alloc]init];
SlideOutMenuTableViewController *SOMTVC = SOMTVC = [[SlideOutMenuTableViewController alloc]init];
UINavigationController *frontNavigationController = [[UINavigationController alloc]initWithRootViewController:HPVC];
UINavigationController *rearNavigationController = [[UINavigationController alloc]initWithRootViewController:SOMTVC];
SWRevealViewController *revealController= [[SWRevealViewController alloc]initWithRearViewController:rearNavigationController frontViewController:frontNavigationController];
revealController.delegate=self;
revealController.rightViewController = SOMTVC;
self.splitMenu = revealController;
self.window.rootViewController = self.splitMenu;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
HomePageViewController.m
//
// HomePageViewController.m
// IndianBloodBank
//
// Created by Roshith Balendran on 8/5/14.
// Copyright (c) 2014 Olympus. All rights reserved.
//
#import "HomePageViewController.h"
#import "SWRevealViewController.h"
#import "AboutUsViewController.h"
#import "SponsorsViewController.h"
#import "HowToDonateViewController.h"
#interface HomePageViewController ()
#end
#implementation HomePageViewController
#synthesize btn1SearchBlood,btn2DonateNow;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0.055 green:0.055 blue:0.059 alpha:1]];
self.navigationController.navigationBar.translucent=NO;
SWRevealViewController *revealViewController = [self revealViewController];
[revealViewController panGestureRecognizer];
[revealViewController tapGestureRecognizer];
UIBarButtonItem *menuButton = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:#"menu-icon"] style:UIBarButtonItemStyleBordered target:revealViewController action:#selector(revealToggle:)];
self.navigationItem.leftBarButtonItem = menuButton;
}
The solution was simple, I just had to turn on ARC.
The basic requirement of SWRevealViewController Class is ARC enabled.
You cannot use this Class for slide out navigation with ARC disabled.
My bad guys. Thought I checked for errors with ARC enabled. My mistake.
So, if you encounter this error "#synthesize of 'weak' property is only allowed in ARC or GC Mode", just turn on ARC.
I have one problem and I've read following solution.This is my code
AppDelegat.h
#import <UIKit/UIKit.h>
#class ViewController;
#interface AppDelegate : UIResponder <UIApplicationDelegate>
#property (strong, nonatomic) UIWindow *window;
#property(strong,nonatomic)ViewController *vobj;
#end
AppDelegate.m
#import "AppDelegate.h"
#import "ViewController.h"
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window= [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.vobj = [[ViewController alloc]initWithNibName:#"ViewController" bundle:nil];
self.window.rootViewController = self.vobj;
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
and it gives an error Application windows are expected to have a root view controller at the end of application launch
This is my code
https://www.dropbox.com/s/y3gzur3tb032nz3/slide.zip
Applications are expected to have a root view controller at the end of application launch
Application windows are expected to have a root view controller at the end of application launch warning
Application windows are expected to have a root view controller at the end of application launch - even with all known issues fixed
and other link...
Thank You.
I found the source of the problem, and I made it work. It is deeper than it seems. The general problem is that on your "synthesised" line, you have also set the 'view' outlet to be synthesised. The 'view' is automatically associated on view creation with the 'view' property inside a view controller by iOS, and you just did an override on that association.
Change your line to this
#synthesize slide1,slide2,slide3,segmentview,segment1,segment2,switch1,newslider,lbl;
and you will be fine. The problem was that although your view controller was instantiated and assigned as a root view controller, its 'view' property was set to nil. You could see that using the debugger. iOS probably interpreted the nil view as an unassigned root view controller, hence the error you were seeing.
On a side note, might I give you some advice on how to save time, redundancy and make your code cleaner? Consider the following code:
#interface ViewController : UIViewController
{
// UISlider *slide1;
// UISlider *slide2;
// UISlider *slide3;
// UIView *newslider;
// UIView *segment1;
// UIView *segment2;
// UISegmentedControl *segmentview;
// UILabel *lbl;
// UISwitch *switch1;
//
}
#property (strong,nonatomic)IBOutlet UISlider *slide1;
#property (strong,nonatomic)IBOutlet UISlider *slide2;
#property (strong,nonatomic)IBOutlet UISlider *slide3;
#property (strong,nonatomic)IBOutlet UIView *newslider;
#property (strong,nonatomic)IBOutlet UIView *segment1;
#property (strong,nonatomic)IBOutlet UIView *segment2;
#property (strong,nonatomic)IBOutlet UISegmentedControl *segmentview;
#property (strong,nonatomic)IBOutlet UILabel *lbl;
#property (strong,nonatomic)IBOutlet UISwitch *switch1;
-(IBAction)btnchangecolor:(id)sender;
#end
Then, your view controller implementation would be like this:
#implementation ViewController
//#synthesize slide1,slide2,slide3,segmentview,segment1,segment2,switch1,view,newslider,lbl;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
-(void)loadView {
[super loadView];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
-(IBAction)btnchangecolor:(id)sender
{
if (_segmentview.selectedSegmentIndex==0) {
_segment1.backgroundColor=[UIColor colorWithRed:_slide1.value/255 green:_slide2.value/255 blue:_slide3.value/255 alpha:1.0];
}
else
{
_segment2.backgroundColor=[UIColor colorWithRed:_slide1.value/255 green:_slide2.value/255 blue:_slide3.value/255 alpha:1.0];
}
_lbl.backgroundColor=[UIColor colorWithRed:_slide1.value/255 green:_slide2.value/255 blue:_slide3.value/255 alpha:1.0];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#end
When you create a #property, modern Xcode versions produce a #property with that name, and sets the internal variable of a property like "myVar" automatically to "_myVar". Before automatic synthesizing feature, you could set the name of the internal variable by writing "#synthesize myVar = _myInternalVar", which would allow you to write "_myInternalVar = newValue" or "self.myVar = newValue" (you can still do that, by the way, if you wish). Seeing your code however, there seems to be some redundancy. You create iVars, and then, you create IBOutlets and then you synthesise the outlets with the name of the iVars. It's not an error, it's not even a warning, but you could save so much time by writing only the "#property" elements and not anything else, that I though I might just throw it as an option :)
I'm new to objective-c so please bear with this long explanation, I hope it will help other beginners. I have been successfully making some changes to an existing iPad app. However, the original install/update routine has hit the failed to launch in time barrier. The posts here have helped me greatly to understand the problem and which direction(s) to research.
I have compiled a solution from different posts here and elsewhere as I did not find a global line-by-line for beginners solution.
I understand that I need to pull the database init/update out of didFinishLaunchingWithOptions and return from here asap with an instantiated UIViewController that will do the DB stuff off the main thread (thanks to all the posters on the subject).
NOTE that the rootVC that is usually called here cannot init if the data is not ready and intact. So just going async on the DB routine doesn't help me because the rootVC gets there first and bombs out when it doesn't find the data it requires.
i.e. I need to delay the rootVC while we do anything we need to do and in peace. I choose to load the UILaunchImage to be seamless and add a spinner.
The question is:
1) Have I done it correctly so that I will never get bitten and 8badf00d again and especially without adding other side effects? Or should I have done it otherwise, maybe in a wrapper init method of the existing rootVC?
2) What about the dealloc, rootViewController or splashViewController? I would think that it is rather rootViewController by this stage. Confused.
3) It works but is this really replacing (and removing) splashViewController by rootViewController as the rootVC? Or am I piling them up...
BEFORE
RAppDelegate.h
#import <UIKit/UIKit.h>
#import "RDataManager.h"
#import "RRootViewController.h"
#import "RScreenViewController.h"
#interface RAppDelegate : NSObject <UIApplicationDelegate>
{
UIWindow *window;
RRootViewController *rootViewController;
}
#property (nonatomic, retain) IBOutlet UIWindow *window;
#property (nonatomic, readonly) RRootViewController *rootViewController;
#end
RAppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[RDataManager sharedManager] updateDatabase]; // This is what takes time...
rootViewController = [[RRootViewController alloc] initAtScreen:kScreenTypeIndex withCar:carId];
rootViewController.wantsFullScreenLayout = YES;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
return YES;
}
...
- (void)dealloc
{
[rootViewController.view removeFromSuperview];
[rootViewController release];
[window release];
[super dealloc];
}
AFTER
RAppDelegate.h
#import <UIKit/UIKit.h>
#import "RDataManager.h"
#import "RScreenViewController.h"
#import "RSplashViewController.h"
#interface RAppDelegate : NSObject <UIApplicationDelegate>
{
UIWindow *window;
RSplashViewController *splashViewController;
}
#property (nonatomic, retain) IBOutlet UIWindow *window;
#property (nonatomic, readonly) RSplashViewController *splashViewController;
#end
RAppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
splashViewController = [[RSplashViewController alloc] init];
splashViewController.wantsFullScreenLayout = YES;
self.window.rootViewController = splashViewController;
[self.window makeKeyAndVisible];
return YES;
}
...
- (void)dealloc
{
[splashViewController.view removeFromSuperview];
[splashViewController release];
[window release];
[super dealloc];
}
RSplashViewController.h
#import <UIKit/UIKit.h>
#import "RRootViewController.h"
#interface RSplashViewController : UIViewController
{
UIImageView *splashImageView;
RRootViewController *rootViewController;
UIActivityIndicatorView *spinner;
}
#property (nonatomic, retain) UIImageView *splashImageView;
#property (nonatomic, readonly) RRootViewController *rootViewController;
#end
RSplashViewController.m
#import "RSplashViewController.h"
#import "RDataManager.h"
#interface RSplashViewController ()
#end
#implementation RSplashViewController
#synthesize splashImageView;
#synthesize rootViewController;
- (void) loadView
{
CGRect appFrame = [UIInterface frame];
UIView *view = [[UIView alloc] initWithFrame:appFrame];
self.view = view;
[view release];
NSString *splashFile = [[NSBundle mainBundle] pathForResource:#"LaunchImage-jaguar-Landscape~ipad" ofType:#"png"];
UIImage *splashImage = [[UIImage alloc] initWithContentsOfFile:splashFile];
splashImageView = [[UIImageView alloc] initWithImage:splashImage];
[self.view addSubview:splashImageView];
[splashImage release];
spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
CGRect frame = spinner.frame;
frame.origin.x = CGRectGetMidX(self.view.frame) - CGRectGetWidth(spinner.frame) / 2;
frame.origin.y = 650;
spinner.frame = frame;
spinner.hidesWhenStopped = YES;
[self.view addSubview:spinner];
[spinner startAnimating];
}
- (void) viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
// how we stop DB refresh from freezing the main UI thread
dispatch_queue_t updateQueue = dispatch_queue_create("updateDB", NULL);
dispatch_async(updateQueue, ^{
// do our long running process here
[[RDataManager sharedManager] updateDatabase];
// do any UI stuff on the main UI thread
dispatch_async(dispatch_get_main_queue(), ^{
[spinner stopAnimating];
[splashImageView removeFromSuperview];
rootViewController = [[RRootViewController alloc] initAtScreen:kScreenTypeGarage withCar:nil needSplashScreen:YES];
[self.view addSubview:rootViewController.view];
});
});
dispatch_release(updateQueue);
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void) dealloc
{
[super dealloc];
}
#end
To answer my questions.
1) Yes this is safe, either with SplashViewController or rootVC init wrapper. Ran it as ad-hoc for 2 minutes no problems. Double checked that the update was indeed running in a separate thread (Xcode debug window pane).
2) Non issue since I moved to a rootVC init wrapper solution and reverted to dealloc'ing rootViewController.
3) Problem solved by 2).
I also managed to reduce the update time by 90% which is the ideal solution anyway, but good to know that I am also safely out of the way of the watchdog timer.
I'm loading an application (via embedded framework) via a PhoneGap Plugin.
Now, I'm trying to pass the current UIViewController to the parentViewController property of the FlashizFacade object.
When I execute my application I'm getting this error in the debug console when assigning self:
2012-09-10 13:01:43.663 gTicketSales[2805:16a03] -[FlashizPlugin navigationController]: unrecognized selector sent to instance 0x91925e0
2012-09-10 13:01:43.665 gTicketSales[2805:16a03] ***WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate:<NSInvalidArgumentException>-[FlashizPlugin navigationController]: unrecognized selector sent to instance 0x91925e0
When assigning self.viewController:
2012-09-10 14:31:21.455 gTicketSales[3693:16a03] ***WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate:<Wrong parentViewController specified>When using non-modal display, parentViewController have to be an instance of UIViewController with a valid navigationController assigned
I've tried:
facade.parentViewController = self;
facade.parentViewController = self.viewController;
My .h file
#import <Cordova/CDVPlugin.h>
#import <FlashizPaymentLib/FlashizFacade.h>
#interface FlashizPlugin : CDVPlugin <FlashizPaymentDelegate> {}
#property (nonatomic, retain) FlashizFacade* flashizFacade;
- (void) openFlashiz:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
#end
My .m file
#import "FlashizPlugin.h"
#implementation FlashizPlugin
#synthesize flashizFacade;
- (void) openFlashiz:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options {
NSLog(#"Flashiz Payment Opening...");
NSString *callbackId = [arguments pop];
NSString *invoiceId = [arguments objectAtIndex:0];
FlashizFacade* facade = [[FlashizFacade alloc] initWithEnvironment:FE_TEST];
facade.parentViewController = self;
facade.delegate = self;
self.flashizFacade = facade;
[facade executePaymentForInvoiceId:invoiceId];
[facade release];
CDVPluginResult *result;
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:#"Flashiz Payment Executed..."];
[self writeJavascript:[result toSuccessCallbackString:callbackId]];
}
#end
Thanks in advance!
On AppDelegate.h
#property (nonatomic, strong) UINavigationController *navigationController;
on AppDelegate.m change this line on application didFinishLaunchingWithOptions
self.window.rootViewController = self.viewController;
for this
UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
self.navigationController = aNavigationController;
self.window.rootViewController = self.navigationController;
In my project is crashing because I don't have a ConnectionViewController, I think I didn't include the framework correctly, because I didn't know whato to do with the Resources folder, but I think it should work for you.
EDIT: I just included the resources folder, and it's working!!!
And if you don't want the navigationBar on the phonegap's view controller put in the viewDidLoad of MainViewController.m
self.navigationController.navigationBar.hidden = YES;