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 7922259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:53:35+00:00 2026-06-03T16:53:35+00:00

I have a UIButton which calls a method from another UIViewController , that method

  • 0

I have a UIButton which calls a method from another UIViewController, that method calls a delegate method which is not happening.

Something like:

FirstViewController

-(void)viewWillAppear:(BOOL)animated {
//Submit Button
    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [button addTarget:self 
               action:@selector(someMethod)
     forControlEvents:UIControlEventTouchDown];
    [button setTitle:@"Submit" forState:UIControlStateNormal];
    button.frame = CGRectMake(100.0, 120.0, 80.0, 40.0);
    [self addSubview:button];
}

- (void)someMethod {

 SecondViewController *viewC = [[SecondViewController alloc] init];
 [viewC otherMethod];

} 

SecondViewController

- (void)otherMethod {

 NSLog(@"Verification.....");
 [self.delegate foo:self Bar:self.text]; //not working when called the otherMethod from FirstViewController

} 

I know I’m doing it wrong way.

  • 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-06-03T16:53:36+00:00Added an answer on June 3, 2026 at 4:53 pm

    A very simple example of the way protocols and delegates work in objective-c

    @class A;
    @protocol DelegateName<NSObject>
    @optional
      - (void)doSomething:(NSString *)text;
    @end
    
    @interface A: NSObject {
        NSString *bar;
        id <DelegateName> delegate;
    }
    
    @property (nonatomic, retain) NSString *bar;
    @property (nonatomic, assign) id <DelegateName> delegate;
    
    - (void)someAction;
    
    @end
    

    This is your protocol declaration.
    Then when you are calling the delegate method, you need an object of the class to invoke the delegate method. In your case it is vc. You set delegate like this:

    [vc setdelegate: self];
    

    Then you invoke method, like you have done.

    See if you are missing any point from this example.

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

Sidebar

Related Questions

I have a UIButton in the UITableViewCell which i would like to toggle it's
I have a background UI Image which is shown whenever i touch a UIButton:
I'm trying to create a UIButton programmatically. I have a button called addCash (which
I have a detail view that includes three UIButtons, each of which pushes a
I have a UIButton with no text and have 2 images I'd like to
I have a UIButton, and I'd like to update its title, but I'd rather
I have a UIButton that is created inside of each table cell. I want
I have a UIButton that performs an Action when it is touched down. I
So, I have a UIButton that, when a UITextField is in editing mode, becomes
I have a UIButton which i add programmatically. No problems here, it stetches as

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.