I have a table view set to as static. it has 4 cells in it. the first two cells are mapped to another view so that works fine,
I would like the other 2 cells to either call a phone number or launch email. I do have the code for both of these functions already. I just dont know who to map the action of a cell selection to a function in the code. when I right click on the cell, I only see push action for segue but I want to control this in the code.
Open the storyboard file and click on the the Assistant Editor button in the top right of Xcode.
It should open up the header file to the view controller associated with the view. Now Ctrl and drag the cell you want to hook your code up to and drag it to the header file. This will create an IBAction for you. Now that it is hooked up, you can then call your method your created to handle the call or email.
Related
I'm looking to make a button which creates new buttons.
So there are already 3 buttons created by me with ViewController.
And on the bottom should be a "create new button" button. So the user can create as many buttons as he wishes. And every new button should be stacked under each other.
https://imgur.com/ttDZQU1
Here is how I build it on ViewController.
You have some ways to achieving this result. You can create a stack view and push the buttons to it. You can programatically add buttons to the screen by creating new UIButtons every time the users click the add button, or you can create a table view, and add a new cell every time the user clicks it. This last approach already supports scrolling (For when your user clicks tens of times, you'll need to able to scroll the screen so they can see the buttons outside the visible frame). In case you choose to go with the first or second, don't forget to add an UIScrollView to your View.
The steps to get this result with a tableview (3rd approach are):
Create a UITableView in the view controller's storyboard.
Set the UITableView datasource and delegate to the view controller
Create a UITableViewCell inside the UITableView, and set its identifier to something related to cell, like "buttonCell", for example.
Add a UIButton to this newly created UITableViewCell, and pin the constraints accordingly.
in the View Controller .swift file, create an outlet for the UITableView
in the tableView delegate cellForRowAt, don't forget to use the right identifier (in our example, "buttonCell").
if you get lost somewhere in the steps listed above, check some tutorials to create a tableview, such as: https://www.ralfebert.de/ios-examples/uikit/uitableviewcontroller/
I am trying to write a project but with out success i need help:
in the first view i have UITableView with a + on the navigator bar than after i push on him
I open a another view there i want to add a first name and after then i click "Done" i want the name i wrote in the textfield will appears on the first view
and thats is my problem the name are not appears in the first view and i have not bug or error .
what can be missing in my project all the button are connected.
I need some help please.
Since you're not showing code, I have to have a pretty general description here. With a button in the nab bar (which is what I think you're talking about) the button calls an action method. Your action method is what moves you to the second view.
Even if your button is "wired up" correctly in your xib file, your action method may not be doing the right thing. I'd try setting a breakpoint in your action method to 1) see if it gets called and 2) step through to see if you're creating a new view and pushing it on the UINavigationController's stack.
Why can't XCode 4 create XIB file while using storyboard: is it 2 incompatible models ? For example all tutorials about hiding keyboards seem to require XIB file:
http://www.techotopia.com/index.php/Writing_iOS_4_Code_to_Hide_the_iPhone_Keyboard_%28Xcode_4%29
Here is an update to the link in the question:
Having written the code for our method we now need to wire up our user interface so that it gets called at the appropriate time. We will perform this task in Interface Builder, so select hideKeyboardViewController.xib once more.
The equivalent of this now is to click on storyboard, and then click the hidKeyboardViewController in the storybaord window.
Select the text field in the view and display the Connections Inspector (View -> Utilities -> Connections Inspector) in the right hand panel.
The equivalent of this now is to Right click the text field.
Click on the circle to the right of the Did End on Exit event, drag the line to the File’s Owner icon and select textFieldReturn from the list of available methods.
Equivalent here is to click the circle, as mentioned, then drag the blue line to the orange box at the bottom.
Its the same, inside the storyboard you will see your views and you can do the same as you did when you were working directly with .xibs
Treat the "scenes" in the storyboard as if they were XIBs. You can layout the screen, add elements, and link them up to their respective ViewControllers. Any code you need to run should be in a ViewController, and then in the Storyboard you can indicate that a particular scene is related to that ViewController.
For your question about hiding the keyboard, you'll need to have a method in your ViewController that includes a line of code:
[myTextField resignFirstResponder];
...where myTextField is a UITextField, UITextView, or other object that requires a keyboard.
I seem to be having an issue. The tutorial I am following from Apple's Dev Center says:
Control-drag a connection from the
Convert button to the
ConverterController instance in the
nib file window.
A black box will pop up similar to
the one we used to connect outlets.
Choose convert:.
Save the nib file.
I usually hold ctrl and drag the mouse from one object to another. However, when selecting a button from my User Interface and trying to drag to an Object in the xib window (this is all in the Interface Builder), the object will not highlight. It just won't let me do it!
Any ideas why this is happening?
you can use the "tree" map of all the objects in your nib file so it is easier to select one. this is helpful if they are on top of each other, hidden, or otherwise difficult to click directly. in xcode 4, there is a little triangle button along the bottom left of the nib view; if you click it, a sidebar opens with a text outline of all your nib's object. you can click the button in this list so it highlights, then control-drag to your file owner to attach it to a method you have written. the sidebar is also useful if you want to re-order objects in a view or subview, to make some on top of others.
Right click the file owner file a pop up will appear in front of you their you can see various action methods that you have in your project.
select a particular action method and then assign it to the appropriate button on which you want to call the appropriate function.
i have this view in my app
http://hpics.li/ce94f6c
the user should put the fly number and he will get informations taht i got from a web service in the table view .
But this table view is small and i want to make one at the height and width of the vie .
Should i hide the label and button and then show the large table view ?
Or should i make a new xib and load it when the user click the button ?
or should i create a new tableviewcontroller with .xib and send to him the json to parase and put in the table view ?
help please
What you can do is to go with your second option.
You can firstly create a ViewController where you have a label and a button field. (You should also put some image is this case as having only a button and a label on complete screen will seem to be odd).
Once you click the button you can call the web service and then navigate to a new viewController where you can display web results in a tableView.