Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 947399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:04:37+00:00 2026-05-15T23:04:37+00:00

I’m working on a basic iPhone app to test some events, and I’m running

  • 0

I’m working on a basic iPhone app to test some events, and I’m running into an error that I can’t understand or find any answers for. I’m not using IB at all (aside from the MainWindow.xib it creates).

Right now it’s about as basic as it could be.

mainAppDelegate.h

#import <UIKit/UIKit.h>
#import "mainViewController.h"

@interface mainAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    mainViewController *viewController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) mainViewController *viewController;

@end

mainAppDelegate.m

#import "mainAppDelegate.h"

@implementation mainAppDelegate

@synthesize window;
@synthesize viewController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    self.viewController = [[mainViewController alloc] init];
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];

    return YES;
}

- (void)dealloc {
    [viewController release];
    [window release];
    [super dealloc];
}

@end

mainViewController.h

#import <UIKit/UIKit.h>

@interface mainViewController : UIViewController {

}

- (void)showMenu;

@end

mainViewController.m

#import "mainViewController.h"

@implementation mainViewController

- (void)loadView {
    UIScrollView *mainView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    mainView.scrollEnabled = YES;
    self.view = mainView;    
    self.view.backgroundColor = [UIColor grayColor];

    [self.view setUserInteractionEnabled:YES];
    [self.view addTarget:self action:@selector(showMenu) forControlEvents:UIControlEventTouchDown];

    [mainView release];
}

- (void)showMenu {
    NSLog(@"Show Menu");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void)viewDidUnload {
    [super viewDidUnload];
}

- (void)dealloc {
    [super dealloc];
}

@end

Now, I get a warning on this line:

[self.view addTarget:self action:@selector(showMenu) forControlEvents:UIControlEventTouchDown];

that says ‘UIView may not respond to ‘-addTarget:action:forControlEvents:’. And this doesn’t make sense, because a UIView subclass can certainly respond to addTarget, and I’m calling it on self.view, which must exist because I don’t release it until the end of loadView. (and even then it should be retained by the controller)

Looking at a trace shows that the actual error is
-[UIScrollView addTarget:action:forControlEvents:]: unrecognized selector sent to instance 0x5f11490

So it looks like it’s a problem with the selector itself, but I see nothing wrong with my selector!

I’m pretty baffled by this and any help would be great.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T23:04:37+00:00Added an answer on May 15, 2026 at 11:04 pm

    First, classes always start with capital letters….

    UIScrollView is a subclass of UIView, not UIControl.

    UIControl implements addTarget:action:forControlEvents:. UIScrollView does not. Thus, the runtime error.

    If you want something to happen in response to an action taken on the scroll view, set up a delegate for the scroll view. See UIScrollViewDelegate‘s documentation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.