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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:57:59+00:00 2026-05-16T10:57:59+00:00

In my application, I need to do some activity i.e pushing otherview controller,when I

  • 0

In my application, I need to do some activity i.e pushing otherview controller,when I click a UISearchbar which is added on view.

what is best approach to achive this.

As one of thing is when we click UISearchbar “searchBarTextDidBeginEditing” get fired,but with my scenario when I push view controller in “searchBarTextDidBeginEditing” and come back searchBarTextDidBeginEditing get called again, so seems it is not ideal place to push view controller.

This is maincontroller

// Search bar
  iSearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, 40)];
  iSearchBar.delegate = self;
  iSearchBar.showsCancelButton = NO;
  iSearchBar.autocorrectionType = UITextAutocorrectionTypeNo;
  iSearchBar.autoresizingMask = UIViewAutoresizingFlexibleWidth;
  [self addSubview:iSearchBar];

when I click UISearchBar then it calls

   - (void)searchBarTextDidBeginEditing:(UISearchBar*)searchBar
   {
   [self ShowMySearch];
   }

In ShowMySearch , I am pushing some other controller lets say searchcontroller and when pop this searchcontroller and come back to maincontroller
“searchBarTextDidBeginEditing” get call again and searchcontroller is pushed again and causing issue. this behavior is seen only on 3.1.1

Thanks,

Sagar

  • 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-16T10:58:00+00:00Added an answer on May 16, 2026 at 10:58 am

    I think calling [self ShowMySearch] in “searchBarTextDidBeginEditing” is a bit too late.
    I suppose that “searchBarTextDidBeginEditing” is called on response to the search bar becoming first responder. Since it is the first responder when the search controller is pushed, it probably become first responder again when your search controller is poped out…thus calling “searchBarTextDidBeginEditing” once again.

    To achieve this, I’d use :

    • (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar

    This method is called after the search bar is tapped but before it becomes the first responder. And if you return NO, it will never become the first responder :

    - (BOOL)searchBarShouldBeginEditing:(UISearchBar*)searchBar {
        [self ShowMySearch];
        return NO;
    }
    

    Let me know if this works !

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

Sidebar

Related Questions

I'm working on application and I need some suggestions which is the best way
I've got some Asynchronous cleanup activity I need to do as my Qt application
I need some advice for a design which I have to implement in application.
Basically I need some suggestions which is the best way to switch views in
I am developing an android application in which i need to give some features
I'm working on a web application and need some help with a query. I'm
I'm looking to a design a protocol for a client-server application and need some
I'm a iOS Application developer.I need some similar tasks in many projects as example
Hokay so I have an application where I need some IPC... I'm thinking named
I need some way to monitor a desktop application and restart it if it

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.