Altering characteristics of 3-party buttons (!) in Xcode - iphone

I'm doing an iPad app in Xcode 4.3
So, I am triggering a function and inside that function, I want to be able to alter the characteristics of other buttons. For example, upon clicking my button (that I made in Interface Builder) linked to the function, I want to have a load of other buttons (also in IB) change text/color.
I've tried the developer book and a good amount of time on google, but I can't find the question asked or answered in the way i'm trying to phrase it (I decided this was the most clear one in the end)
I know I can easily edit the name of the button I've used to call the function
[MYBUTTON setTitle:(NSString *) TITLE forState:(UIControlState) STATE];
but I can't figure out how on earth to edit other buttons I've added in the interface builder. Is this possible, or do I need to deal with the buttons more programmatically?
so far in my function, I've called the IBAction and made a load of tags to relate to the buttons that I want to change - am I heading along the right road?
Hope this is clear about what I'm trying to achieve, and be gentle with me, my objective C isn't that good yet!

You can mark button properties or instance variables with the IBOutlet marker and then hook the buttons in Interface Builder up to your object.
Also, it isn't a good idea to have all capital letter variable names. In C convention, those are usually reserved for preprocessor macros.

create IBOutlet properties for each button in your view controller, link them in IB or Storyboard and finally change their properties in your method :)

Related

How do I add functionality to a UI made in storyboard?

I have made a pretty little UI on storyboard but I'm quite new to XCode and Objective C (coming over from Java) and I'm having some trouble adding functionality. I know that I should make a subclass of UITableViewController (storeTableViewController) and set the class of the storyboard controller to that. The problem is that when I do that all my hard work in the storyboard is erased, and I can see where the code is conflicting with the showing of my UI (for instance, the tableView:numberOfRowsInSection returns 0 always), and I think that with enough time and patience I could program the UI, but is there any way that I can use all this work that I've done on the storyboard and still be able to add functionality? I want to set a text box at the top to be the first responder as well as be able to change an image and labels on command programmatically.
You should probably use IBOutlets. Connect the StoryBoard UI Object to IBOutlets and you can modify the properties of the UI objects from the code
You can declare IBOutlet link this
IBOutlet type variableName
Check this tutorial video which will help you a lot.
Video Link
I use the storyboard as a canvas. I plug in the outlets that I want and all the little details and then I go around and built the classes. That being said, you need to declare a urtext field outlet (depending to what you want it to do) then add the delegates necessary and allow it to perform on selector. Then you can declare the function. Linking it in storyboard is easy by control and drag.as far the image you can use an uiimage and declare its function and how it changes depending to what the changes are the code varies. My suggestion is to take screen shot of your storyboard and post it with your question so I/ we can help you with the code. But as far as your question goes I hope this answer satisfies you. Happy coding.:)

iPhone keyboard on UiPopOverController (iPad)

i would to know if there is a way to show(call) an iphone-uikeybord-like inside a UIPopOverController. I've an ipad app with several functions, in one of these there is a button that show a popoover, inside the popover there are a uitableviewcontroller and a search controller for search functions inside the table; search stuff is numeric only and i want show a keyboard(like numberpad in iphone) inside the popover instead show the maxi ipad keyboard.
Thanks in advance.
Sure you can do that - but you'll have to build a custom keyboard.
I did exactly the same thing to create a numeric keypad after playing around trying to use a different UIControl for the text field input without much success.
My solution was specific to our app because we also wanted - and + keys to adjust the value without by tapping, but what I ended up doing was:
extend UITextField
add - and + buttons next to it
add a transparent button on top of the numeric field
trigger UIPopOverController when the transparent button was tapped
the popover loaded a NumericKeypad with it's own view
Although I usually try to use IB as much as possible in this case all buttons and target assignments were done in code (for easy of calculating relative positions in code)
The creation of the keyboard itself is really easy - it's just a bunch of buttons. You can either build in IB or programmatically - quite simple either way.

iPhone Built-in Timer (Clock) App

How would one go about recreating the iPhone 'Timer' section of the iPhone built-in 'Clock' app?
I am not asking about specifics (I am a developer and code objective-c, etc), but rather am trying to learn proper design patterns. I have included a screenshot of the app below.
I understand that the first portion of the app is an UIDatePicker. What types of objects are the "When Timer Ends" and "Start" buttons? The "When Timer Ends" portion looks like a UITableViewCell, and the "Start" button looks like a UIButton. Are all 3 of these objects in one UITableView? How would one go about creating the gradients belonging to the "When Timer Ends" and "Start" objects? Are these simply images? Or are the gradients created Programmatically?
I generally like to stay away from Interface Builder and code my views Programmatically.
Thanks a lot!
There is no need for a UITableView here.
In my opinion, there can be a UIDatePicker and 2 UIbuttons. The buttons use 2 different backgrounds - but they are simple custom buttons.
For the When Timer Ends there is also a UILabel to display Digital as this will change accordingly with the user's selection.

Focus and zoom in on a UITextField when touched?

How in the world does one get the iPhone view to zoom in on a focused UITextField? I need to tap on a text field that I want to edit, and my view should zoom in to the tapped text field and pull up the keyboard (which it already does), similar to how many Internet text fields gain focus on the iPhone. Is this some type of overlay?
I've been looking everywhere for this solution but maybe I've just got the wrong terminology. Thank you in advance.
Could be a duplicate of this StackOverflow question.
In essence, there are a number of ways, but you have to program this effect manually. A textfield is already an overlay. You can either move it, or scroll the containing view.
Please follow the following steps.
Implement the delegate method for all textfield.connect the outlet of textfield in interface builder basically it's setting the delegate property.then in delegate property you can defined the method whatever you want to implement or wanted to do functionality.
Thanks

More than 1 button on the left side of a NavigationBar

Is it possible?
I have a UINavigationBar that I'd like to have an 'edit' button next to the 'back' button. From what I've read you can only have one or the other, which makes no sense as they are separate properties of the navigationItem object(backBarButtonItem and leftBarButtonItem).
I'm assuming you have to somehow insert a custom UIView into the UINavigationBar. I'm looking into this option and if no better solution is given then I'll outline this method.
The short answer is:
Yes, you have to add your own UIButton views (or other UIControl subclasses) to the navigation controller, yourself. So, ignore the custom *ButtonItem properties and roll it yourself.
A little more involved answer is:
Apple makes it very easy to follow their HIG guidelines, but you're on your own if you want to break them or customize. In this case, only one button is allowed, because the actual hit region is bigger than the size of the displayed button--much easier to hit from a usability standpoint.
Extraneous:
btw, there is a subtle distinction between left/rightBarButtonItem and backBarButtonItem. left/right is specified on the current UIViewController. However back is specified by the previous UIViewController.
Using a custom view is indeed your only option here. The UINavigationBar is not terribly flexible. What you will need to do is create a UIView that contains UIButtons. Be sure you realize that if you use a custom view, you gain none of the automatic behaviors of the backBarButtonItem; you have to create your own IBActions, and the graphics for the buttons as well.
On a related note, I'm not sure this is the best idea. It's usually wise to stick to Apple's UI guidelines; is there no where else you can put the edit button? The right side of the bar, for example?
While #Kelvin's answer works for pre iOS 5, if you're using iOS 5+ there is now a leftBarButtonItems array property. Note that you also must set leftItemsSupplementBackButton to true.