how create a view when custom button click - iphone

new developer on iphone,please any one have an idea about my problem tell me.in my application take two views one login another one is main message view,user enter valid username,password when click login button main message view will display i wrote for this but my problem is in main message view i place tableview to display all messages and rigth side of this tableview place a button type is custom when click this button add a small view(this view add to main message view both view will display at that time)on that new add view we have to add some buttons one by one(world,country,state)when click world button data change on main message tableview.

please elaborate the problem.
Where exactly you are having problem?
In adding view? or buttons?... you are saying you want to add button one by one....... is it side by side? or you want to give some time delay to add these buttons?
Or you are having problem in data updation on main view?
But as your question title suggests you are having problem in creating the view. I think you want know how to add action with that custom button?(not sure)
[yourBtnObject addTarget:self action:#selector(yourBtnAction:) forControlEvents:UIControlEventTouchUpInside];
here in above code you have to define method:
-(void) yourBtnAction:(id)sender{
//you code goes here for creating and adding the view.
}
also, yourBtnObject denotes your customButton reference ..... change the names as suitable.
Thanks,

Related

Add data with another view on app objective c

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.

how to transfert informations from one view to another

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.

Where should I "save" changes in my iPhone view to 'create new' of an object?

I have a view that creates a new core data managed object, and fills in all the required properties and also allows optional ones. I originally had a "Done" button on the top left, and when that was pressed, I validated the object then saved and removed the view.
Now I have an edit/done type setup on the top right, so sometimes there are two identical "Done" buttons on the top of the view. I want to switch the left side button so that it just has the normal "Back" button, then somehow validate and stop the view from being removed if it doesn't validate. I can't find any way to capture the method called by that back button and modify it, and viewWillDisappear doesn't work cause there's no way to abort the disappearing.
How can I make this work? I need to validate this, then save, then remove the view if validate and save worked only.
It sounds like your view is a perfect candidate to be pushed modally instead of through the navigation controller stack.
Push the view that creates your NSManagedObject modally:
[self presentModalViewController:yourViewController animated:YES]
Then continue to use your top right EDIT/DONE button for editing/validation as you currently are and when validation is successful simply save your object and dismiss the modal view controller from the parent view controller:
[[self parentViewController] dismissModalViewControllerAnimated:YES];
For more details check http://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html#//apple_ref/doc/uid/TP40007457-CH111-SW14
If you still want to use a button on the left hand side perhaps you can change the right button to say EDIT/CANCEL and add a DONE button on the left side that is only visible when you're not in EDIT mode. If appropriate you can point the DONE button to run through the same validation process before dismissing the modal view using the code above but it probably makes sense that the EDIT/CANCEL button takes care of it.
I hope this helps.
Rog
There is no documented way to intercept the standard back button of UINavigationController. If you want this functionality, your only option would be to customize leftBarButtonItem with a custom button.
When the user taps that button, you can first validate your object and then call popViewControllerAnimated:.
It's hard to mimic the look of the built-in back button, though.

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;

Navigating iPhone Views/ViewControllers

In my iPhone application, I use a Tab Bar Controller with five items for the main navigation. However, I also need additional ways to change the current view. For example, if the user is on the Calendar tab and clicks on a date, they need to be shown a different view.
In order to implement this (and other) types of custom navigation, what do I do? I thought what I needed was to add the Navigation Controller to my Main Window nib, but this looks like it adds a navigation bar to the UI, so I don't think that's it. Basically, what is the best way to change the view when a user clicks on something like a button or item on a grid? I know how to hook these interface items to events, but don't quite get how the logic to change views goes in the Main Window nib.
Thanks!
EDIT: To clarify, I believe what I'm trying to do is navigate to a child view for that tab (not change the active tab). As Griffo commented, yes, I am trying to assemble most of the workings in IB and then tweak the code as necessary. I will be trying the approach from his attached link and reporting back.
I think this SO question answers your question
How about showing modal dialog? For instance if you have UIButton in your tab controller:
associate it with method:
[myButton addTarget:self action:#selector(onDoSomething:) forControlEvents: UIControlEventTouchUpInside];
in method -(void)onDoSomething:(id)_sender open your modal dialog:
[self presentModalViewController:mDoingsomethingController animated:YES];
implement "doing something" controller class and supply it with 'done' button and method 'onDone' containing
[self dismissModalViewControllerAnimated:YES];