Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TTViewController and popupViewController method

I'm using a TTLauncherView and for that I declare a view controller as TTViewController, as is in TTCatalog tutorial app. Declare a TTLauncherView var inside that view, add items, and so on.

In my app's main view is a button calling the previous view with the following code:

-(void) switchToButtonOrderingView
{
    ButtonOrderingViewController *ButtonOrderingView=
    [[ButtonOrderingViewController alloc] initWithNibName:@"ButtonOrderingViewController" bundle:nil]; 
    self.ButtonOrderingViewController = ButtonOrderingView; 
    [self.view insertSubview:ButtonOrderingView.view atIndex:10];
}

When I press the button the app brakes up at this method which belongs to TTViewController.m:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  UIViewController* popup = [self popupViewController]; //brakes up here
  if (popup) {
    return [popup shouldAutorotateToInterfaceOrientation:interfaceOrientation];
  } else {
    return [super shouldAutorotateToInterfaceOrientation:interfaceOrientation];
  }
}

and the error goes like that:

[ButtonOrderingViewController popupViewController]: unrecognized selector sent to instance

Checked to see Three20 Class Hierarchy and TTViewController is a UIViewController subclass.

popupViewController is a TTPopViewController (and its subclasses) method! Which I'm not using nor do TTCatalog tutorial app. I'm lost. Any help will be appreciated.

Thanks.

like image 655
BigJoke Avatar asked Jan 26 '10 13:01

BigJoke


People also ask

What is the difference between ViewController and UIViewController?

Both are used for different purpose. A UIViewController class manages a ViewContoller which is responsible for actions that happen within that View controller. This class is aware of actions that happen on view controller, like ViewDidLoad, ViewWillApper, ViewDidAppear, ViewWillDisapper, ViewDidDisapper.

How do I get topViewController?

In addition, you can check for UINavigationController and ask for its topViewController or even check for UITabBarController and ask for selectedViewController . This will get you the view controller that is currently visible to the user.

What is a UIViewController?

A UIViewController is an object which manages the view hierarchy of the UIKit application. The UIViewController defines the shared behavior and properties for all types of ViewController that are used in the iOS application. The UIViewController class inherits the UIResponder class.

How do I know if a ViewController is visible?

The view's window property is non-nil if a view is currently visible, so check the main view in the view controller: Invoking the view method causes the view to load (if it is not loaded) which is unnecessary and may be undesirable. It would be better to check first to see if it is already loaded.


1 Answers

Had the same issue and found the error!

This is what happens when you forget to add -ObjC and/or -all_load to Other Linker Flags according to the Three20 setup instructions. Could be that you added them to the project level, and have an overriding setup at a lower level - that was the case for me.

like image 76
eliego Avatar answered Oct 16 '22 23:10

eliego