how to transfert informations from one view to another - iphone

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.

Related

Add a product in my shopping list - Creating a shopping list app

I've created a product page. Next to the product name, there is a + button. What is supposed to happen when clicking the + button, the product will be added to my cart. How do I do it? I have tried different ways to do it, for example, when clicking the + button a image of the product will show in the cart. But when I press the button, the app crash and I don't know why... Are there any other options for how to do it?
Here is an image of my product page (left) and my cart (right).
I see no outlet between your view controllers. Keep in mind that you can only show one view controller at a time. I can also see that you created a big view controller hardly. You should do it programmatically...
Go on this page : https://developer.apple.com/library/archive/referencelibrary/GettingStarted/DevelopiOSAppsSwift/CreateATableView.html , you'll learn how to create Table View, it will be really usefull for what you are trying to do.
Then you will have to pass data between controller so i suggest you go there : https://learnappmaking.com/pass-data-between-view-controllers-swift-how-to/
One possibilitie is that you have an outlet in your button that do not reach your view controller. To solve this try right clicking the button and deleting all outlet. The you can connect them again and it should not crash.

How to add an "Add Button"- Button

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/

Custom popup view in Swift (Interface Builder)

Is there any way I can show a custom popup in the middle of the screen (over the current content) with buttons and a textfield and anything else I may need, entirely in interface builder?
If this isn't possible, then I don't mind doing it programatically.
I am guessing you create a custom view with the content but I am not sure how I show that view when a button is clicked and bring it up over the current view controller.
Thanks!
I would create a View and a Viewcontroller for it- set the alpha of the view to zero so its invisible - then but a nice picture as background for the custom popuop on it ( as background for the popup) on this i would put the buttons and the text label. VoilĂ  - costum pop-up is ready to present with a segue (choose type over the current view controller).

Static table view - disclosure indicator to call phone number

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.

Edit, select value from UITableView on the iPhone

I have a UITableView with a list of names, representing server configurations. I want the user to be able to select a server configuration, add a server config, edit a server config, or just cancel out of the view and return to the main view. I'm having a hard time trying to figure out how to achieve all of that functionality in this view.
To select, the user should be able to just tap the server config name and a check will appear next to the name then the user is taken back to the main view automatically (or use a save button instead?). To edit the server config, I would also like the user to be able to tap the server config name and be taken to a detail screen where changes can be made. How can I accomplish both since I want both to be done by tapping the server name (row)? Right now the cancel button seems out of place since the screen is accessed via a UINavigationController.
Any suggestions?
alt text http://img94.imageshack.us/img94/6448/screenshot20100325at541.png
Have you considered a detail disclosure button? this effectively gives you two "hot points" on each tableViewCell:
1- The detail disclosure button itself which, according to Apple's HIG, should take you to a detail view.
2- The rest of the cell which you could use to make your selection and pop the view controller.
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;