Knowing the exact method call when tap on iOS app - ios

Is there any quick way to know which method is called when we do any activity on iOS app. I have the code but this is written by some other team and I am trying to find out the action that is happening when I tap on iPad. Is there any way to know about it. I tried putting break points but it does not help.

Following ways out of many can help you:
Find out all methods that have IBAction mention in the start in your .m file. Put a break point on them.
Goto .storyboard or .XIB file of your respective controller, in the right pane check Connection inspector. This inspector will be divided into two halves first belongs to IBOutlet, you have to check the second one which is IBAction. Find them in your .m file and put a break point on it.
Check .h file for any IBAction methods, find its implementation in .m and put a break point on it.
Trace any IBAction selector(s) specified via addTarget function.
Hope it can help!!

Related

Where do I detect where the outlet is from in Xcode?

I downloaded a project from GitHub and I'm experiencing some problems when detecting where a referencing outlet comes from.
This is an UIImage called "backgroundImage".
This is a UIViewController called "WalkthroughPageContentViewController".
"backgroundImages" has two outlets references, one of which is connected to the "WalkthroughPageContentViewController" UIViewController.
But there isn't any #IBOutlet connection here.
So where does the first referencing outlet come from?
I had a quick look at this project, and the answer is that the referencing outlet doesn't come from anywhere. It's broken. If you examine the destination, the you'll see that Xcode knows this is a problem:
And if you open up the WalkthroughPageContentViewController.swift file, and add an outlet called backgroundImage, then close and reopen the file, you'll find it's magically been linked back up to the Storyboard:
So, I'd surmise that at some point, there was an outlet in the file called backgroundImage, which was hooked up to the Storyboard, but then it was later deleted, leaving the project in this state.
This is pretty common when editing projects in Xcode. The Storyboard connections are basically just stored in XML in the .xib file, and there's no magic two-way connection between them and the code at design time, so if you delete the lines of code that they point to, you'll end up in this state.

iOS Objective-C IBAction runs the code in method twice

I tried to run this method of code
- (IBAction)signInButton:(id)sender {
NSLog(#"Run Action %#", #"Here");
}
The result of this code log the "Run Action Here" twice in the console.
I initially loaded all my project import file (.m and .h) in one header file "Loader.h", I taught this was the cause, but I still experience the same issue even after I dissembled the header file.
Same Issue happens on other view controller.
What am I doing wrong ?
Thanks in advance.
It sounds like you've connected the action to your button or other UI element for two different events. For example, if you connect it to both the touch down and touch up events, a single tap of the button will trigger the action twice.
One thing you can do to diagnose the problem is to control-click on the view controller containing the action in your nib or storyboard and look at the Received Actions section near the bottom of the resulting popup. You'll likely see your action connected twice.
Another option is to set a breakpoint in the action and take a look at the sender parameter each time you hit the breakpoint. This will show you what object is triggering the action each time.
This seems to be some problem with the logging. It indeed logs twice from IBAction handlers. I put NSAlert, to make sure it's called twice, but it was called once, nevertheless the log was printed twice in the console.

My view controller in storyboard will not connect to the viewcontroller.h file or the .m

I'm sort of new to xCode so i really don't know much about it. I'm having a problem with my .h and .m files. when I control click on of the view or the pan gesture recognizers, it wont connect. It's been two days and I still don't know. I do have multiple view controllers, but I wanted to make a slide-out menu drawer like the one on the Facebook app.
Did you forget the class name?
check if the target actionof the .m file of objective-c class is checked in the attribute or identity inspector. if it is not checked the make it checked. hope it works...
If you are just looking for a library that does the slide in behavior as Facebook and others take a look at: https://github.com/SocialObjects-Software/AMSlideMenu
or follow Ray Wenderlich's tutorial: http://www.raywenderlich.com/32054/how-to-create-a-slide-out-navigation-like-facebook-and-path

Not all UITextFields are calling all delegate methods

I've got a view controller xib file with several views in it. I'm building a wizard-type interface. I'm just doing a simple fade between the views, and I'm already using a navigation controller for the main interface. I'd prefer not to use one for this wizard. Anyway, in the views, each panel has at least a button, some sort of input field (usually a UITextField) and some helper text hard coded in a UILabel.
The problem is that not all the UITextField objects are calling the textFieldDidChange method in the delegate (File's Owner - .m file associated with the xib), but all the UITextField objects ARE calling the textFieldDidBeginEditing method.
Makes no sense to me. I feel like I must be missing something simple in how I set up the screens, but I'll be darned if I can figure it out. Each of the screens all look identical in the property sheets (on the right hand side of Xcode), and everything is wired up correctly in the File's Owner property sheet, both in IBOutlet and IBActions.
Here are some shots of what's going on...
Ideas? Thanks.
Here are links to the screen caps of the vital parts.
(being a new member is making it hard to add all the info I need with screen caps!)
As far as I now, there is no delegate method with the header textFieldDidChange. You have created a method of your own, which is depending on a NSNotification. Make sure all the UITextFields are send the right notification.
There is no such method on a UITextFieldDelegate
You may have confused textViewDidChange, which is a delegate method for a UITextView, but itis passed the UITextView that generated the event, not an NSNotification.
Seems like you want textField:shouldChangeCharactersInRange:replacementString: instead.
This is resolved. I'm a knucklehead. :-)
I was attaching my own notifier/observer and hadn't done so for the last few UITextField objects. Sorry to bother y'all.

How to call one xib file from another class,ios

I have googled a lot, but some where I am doing a mistake regarding the xib file. I have four buttons in view controller.xib file. Then when I tap the button one two three, alertinputtypetext has to be dislayed. Its done successfully.
But when i tap the fourth button, I need to display pickerView.xib. But when I am debugging the application, the application sequence is missing and showing the main.m class.
Please help me somebody. Give me hint to proceed further.
"I need to display the another file pickerView.xib" ?.. if pickerView is UIViewController subclass you could show it simply .. if its just a nib file contains a pickerView , you could use loadNibNamed:(NSString *)name owner:(id)owner options:(NSDictionary *)options , but actually you don't need to put it in separate nib file .. xib can hold more than one view inside it , so you could use you original viewController.xib , or what I prefer is to it programmatically without loading it from xib.

Resources