-[UIView setShowsFPS:]: unrecognized selector error - uiviewcontroller

I need to open a ViewController when a UIButton was press , for doing that I use the following
code :
NSString * storyboardName = #"Main";
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil];
UIViewController * vc = [storyboard instantiateViewControllerWithIdentifier:#"ViewController"];
[self presentViewController:vc animated:YES completion:nil];
when it take the final line
[self presentViewController:vc animated:YES completion:nil];
it give me the following error:
-[UIView setShowsFPS:]: unrecognized selector sent to instance 0x9bd5610 2013-07-16 14:40:52.728 ChainZoo[3026:a0b] * Terminating
app due to uncaught exception 'NSInvalidArgumentException', reason:
'-[UIView setShowsFPS:]: unrecognized selector sent to instance
0x9bd5610'
Anyone knows the error?
thanks in advance!!

On the storyborad, select your ViewController's view and click "Show the identity inspector" (third little tab on the top right side).
You'll see Custom Class textview.
Write "SKView" and try to run again.
You should init your VC's view as a SKView.

Related

Change view when didReceiveRemoteNotification

I am trying to change from the App delegate method to the Master View when I receive a Remote Notification, in order to perform a segue in the Master View to another view, but I am getting an NSInvalidArgumentException
Code in App Delegate when didReceiveRemoteNotification:
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
EmergencyMasterViewController* maincontroller = (EmergencyMasterViewController*)self.window.rootViewController;
[maincontroller alert];
}
Code in MasterView:
-(void)alert
{
[self performSegueWithIdentifier: #"Warning" sender: self];
}
And the error I am getting: [UINavigationController alert]: unrecognized selector
It is because your window rootViewController is actually a UINavigationController instead of your EmergencyMasterViewController. You need to check how you assign the window root view controller in your app delegate didFinishLaunchingWithOptions or something similar.
Try to get the view controller embedded in the navigation controller, for example:
UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
NSArray *viewControllers = navigationController.viewControllers
EmergencyMasterViewController *maincontroller = [viewControllers objectAtIndex:0];
It might be safer for the UINavigationController to pop to root view controller first before you try to get the EmergencyMasterViewController, in case the user is already navigating his way through the navigation stack:
[navigationController popToRootViewControllerAnimated:NO];

A view can only be associated with at most one view controller at a time. UIViewControllerHierarchyInconsistency

I have this problem on iOs6 on iOs5 works just fine.
this loads the LoginView
- (void)viewDidLoad {
if(!currentView ){
currentView = [[Login alloc] init];
}
self.view = currentView.view;
[super viewDidLoad];
}
And this is on AppDelegate
if (!mvc) {
mvc = [[[mainViewController alloc] init] autorelease];
}
[window addSubview:mvc.view];
[window sendSubviewToBack:mvc.view];
[window makeKeyAndVisible];
2013-01-15 18:02:33.137 fodboldfabrikken[5412:19d03] * Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'A view can only be associated with at most one view controller at a time! View > is associated with . Clear this association before associating this view with .'
* First throw call stack:
(0x2097012 0x1c78e7e 0x2096deb 0xa90309 0xb275ac 0xb23a90 0x3206 0xb23817 0xb23882 0x2b49 0xa3f7b7 0xa3fda7 0xa40fab 0xa52315 0xa5324b 0xa44cf8 0x2aafdf9 0x2aafad0 0x200cbf5 0x200c962 0x203dbb6 0x203cf44 0x203ce1b 0xa407da 0xa4265c 0x2a4d 0x2985 0x1)
libc++abi.dylib: terminate called throwing an exception
You are not allowed to have a controller inside another controller which is what you are doing here mvc = [[[mainViewController alloc] init] autorelease];

Segue not transitioning to next view?

I have been trying to figure this out for well over 3 hours now. After I successfully authorize my login with facebook, when the view tries to transition to the next view, it crashes with sigbart error: [4923:c07] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key SegueToScene1.'
This is my segue to scene:
- (IBAction)loginButtonTouchHandler:(id)sender {
// Set permissions required from the facebook user account
NSArray *permissionsArray = #[ #"user_about_me", #"user_relationships", #"user_birthday", #"user_location"];
// Login PFUser using facebook
[PFFacebookUtils logInWithPermissions:permissionsArray block:^(PFUser *user, NSError *error) {
[_activityIndicator stopAnimating]; // Hide loading indicator
if (user.isNew) {
NSLog(#"User with facebook signed up and logged in!");
[self performSegueWithIdentifier: #"SegueToScene1"
sender: self];
} else {
NSLog(#"User with facebook logged in!");
[self performSegueWithIdentifier: #"SegueToScene1"
sender: self];
}}];
[_activityIndicator startAnimating]; // Show loading indicator until login is finished
}
My question is, why does xcode keep refusing the segue?
Edit: I deleted my segue and put a new one "SegueMain", then changed the code to reflect that, but strangely, it still returns the same error with SegueToScene1. How strange is this? There is no trace of that title left...anywhere. Yet, it remains...
I imagine you have something connected in interface builder to perform the SegueToScene1 segue. To find it you could try searching the plain text version of your storyboard or you should probably have an idea of where it would be.

UIViewController.navigationController becomes nil

I bumped into a problem where UIViewController.navigationController becomes nil and I'm desperately trying to find an answer to this one.
The UINavigationController gets setup in the application delegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.rootViewController = [[RootViewController alloc] initWithNibName:#"RootView" bundle:nil];
UINavigationController* navigationController = [[UINavigationController alloc] initWithRootViewController:self.rootViewController];
[self.window addSubview:navigationController.view];
[self.window makeKeyAndVisible];
return YES;
}
When the RootViewController is appearing, the self.navigationController member is set and I can use it to hide the navigation bar, like so:
- (void)viewWillAppear:(BOOL)animated {
NSLog( #"self = %#, self.navigationController = %#", self, self.navigationController );
[self.navigationController setNavigationBarHidden:YES animated:NO];
}
The debug output shows values for self and self.navigationController.
When a button is clicked in this controller, self remains the same value indeed but self.navigationController is now nil:
- (IBAction)buttonClicked:(id)sender {
NSLog( #"self = %#, self.navigationController = %#", self, self.navigationController );
// here, self.navigationController is nil, so
// [self.navigationController pushViewController:...] doesn't work :-(
}
I've seen dozens of questions regarding this problem and the answer is always that the UIViewController is not part of a UINavigationController. Since accessing the navigationController in viewWillAppear works fine, I believe something else must be going on. Do you have any pointers? I'll happily provide more detail if necessary.
Try this in the app delegate:
[(UINavigationController *)self.window.rootViewController pushViewController:yourViewController animated:NO];
the rootviewcontroller is actually UINavigationController if you po to debug it. This works for me.
Your code shows that you are only using the navigationController's view but just pray that navigationController life is handled by some magic hand which is not the case.
You need someone to be the explicit owner of the navigationController here.
In fact, the following line:
[self.window addSubview:navigationController.view];
seems to indicate that what you want is for the window's rootViewController to be navigationController:
self.window.rootViewController = navigationController;
But also, it seems that the application's delegate is to be an owner of navigationController as well so navigationController should, in fact, be an ivar of your app's delegate.
In short, fix your object graph (and it will coincidentally do the extra retain you manually did and fix your bug)
I had a problem with a nil view controller and found that it was not connected properly in storyboard to the app delegate.
As always, it helps to formulate the question just to find the solution some minutes later.
I fell prey to ARC, I guess. Once I retained the UINavigationController in the application delegate, it worked fine.

implementing TTThumbsViewController on a UIViewController?

Im trying to implement add TTThumbsViewController as a subview of UIViewController but the app is crashing. Here you see the code-
.h file-
#import <UIKit/UIKit.h>
#import <Three20/Three20.h>
#import <Three20UI/UIViewAdditions.h>
#import "MockPhotoSource.h"
#interface photos : UIViewController <NSXMLParserDelegate, TTThumbsViewControllerDelegate>
{
TTThumbsViewController *photoSource;
...........
}
.m File-
- (void)viewDidLoad {
// parsing a feed
[self parseXMLFileAtURL:#"http://feed203.photobucket.com/albums/aa15/vikysaran/Worst%20Parents/feed.rss"];
NSMutableArray *arr = [[NSMutableArray alloc]init];
for (int i=0; i < [stories count];i++) {
[arr addObject:[[[MockPhoto alloc] initWithURL:[[stories objectAtIndex:i] objectForKey:#"fullimageurl"] smallURL:[[stories objectAtIndex:i] objectForKey:#"thumburl"]
size:CGSizeMake(960, 1280)] autorelease]];
}
photoSource = [[[MockPhotoSource alloc] initWithType:MockPhotoSourceNormal title:nil photos:[NSArray arrayWithArray:arr] photos2:nil]autorelease];
// till here the code is working fine if i am not using uiviewcontroller
NSLog(#"mockphoto%#", arr);
[self.view addSubview:photoSource.view];// adding to uiview
}
here is the error displays-
-[MockPhotoSource view]: unrecognized selector sent to instance 0x6924ca0
2011-09-22 13:07:07.375 JesonTerry[1969:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MockPhotoSource view]: unrecognized selector sent to instance 0x6924ca0'
Please anybody help. i am totally confused where i am wrong...
your view controller has to be a type TTThumbsViewController and not a UIViewControler for starters.. Check the TTCatalog app in the samples folder