Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
hi i am new to iphone. what i did is creating two classes named view1 view2. And i create a button in view1. now what i need is when ever i click the button in view one it goes to viewdidload in view2 how can i done this pls post some code or link. thank u
You're violating principals of MVC. Views should never talk directly to one another. If you need to signal some change in one view upon some event from another view, you need to route it through your controller.
I.e., a push of a button might change a label. In this case, the button receives an event (touches up or whatever) which get routed through its delegate (some controller). This delegate can then signal some action which then changes the text of the label (the second view).
I strongly suggest you become acquainted with the model-view-controller paradigm. It will give you insight into how the frameworks are constructed, and enable you to better write code targeting these frameworks.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 months ago.
Improve this question
Hiii !
it's my second app on Xcode.
I noticed that my navigation item is not a button but a "drop down" and I don't know why
How can I change it ? Image: navigation item
So from the comment, I will answer detail about your problem for futher reader and yourself.
As Swift there is two types of tranfering to from view controller to another view controller
First one is using presentViewController which is presents a view controller modally. Just like from your image and we usually use it for task you don't want user to navigate from so just two methods cancel or continue. Example: Sign In, Sign Up, ...
Second one is using pushViewController which will have a Back button just like you want in the navigation bar. And in this case you can control your own controller, callback, ... Remember to define what is root view controller by using Embed in Navigation controller if you use storyboard or define by code by using
UIApplication.shared.windows.first?.rootViewController = vc // your view controller
What you're dealing with is that your storyboard or screen is as a sheet.
Segue set as Page Sheet
Changing this to full screen will give it a bar, but you may need to embed the scene into a navigation control to create a bar. You can do that via Editor -> Embed In -> Navigation Controller.
Segue set to full screen
Embedded into Navigation Controller
The navigation controller color is set to black to be noticeable.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have two screens which have half of the content same. I need to navigate from one view controller to another. Do I need to create both screen's content separately or there is an another way.
I hope I am clear with my question!
Create your own UIView subclass an implement all filter ui there. Then use Your FilterView in both Controllers.
Example
This question already has answers here:
How execute code every time that I view a page
(3 answers)
Closed 5 years ago.
I have a view (View1) which sets a variable needed by the view (View2) it navigates to. The user can go back to View1 and select a button to change the variable, then click submit to go to View2 again.
View2 calls an OData service in its onInit() method, and uses this variable as part of the call.
How do I ensure View2 is always performing this function every time it is navigated to? I tried doing .destroy() but that removes the ID and it can't be reused by View1.
Are both views living inside a sap.m.NavContainer or sap.m.App (which derives from it)? Then you can use the "beforeShow" event that the NavContainer fires on each child (in your case the View), see
https://openui5.hana.ondemand.com/#docs/api/symbols/sap.m.NavContainerChild.html
(you would call the addEventDelegate(...) on the View)
You are not using the Routing, right? I think it would provide sufficient hooks.
However, also think about whether data binding could be used in your situation. In the most simple case, View 1 would only need to change the binding context and the ODataModel would update the data for View 2 automatically.
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 11 years ago.
I'm working on an iPhone app that has a UITableView with multiple entries and when you click on each, it takes you to the same view using a navigation controller. This is good, I want the same view every time, except for one of my entries I want to hide a text label. I have succeeded in doing this, except I did it in the viewDidAppear method, so when I push the view from the side, it shows up for just a split second before it disappears. How do I fix this so that it never shows up?
Thanks,
VectorWare
That requirement calls for the viewWillAppear method.
You can and should do all kinds of modifications to your view inside that method.
All modifications will be applied to the objects in the current view before it gets shown via the loadView or viewDidLoad methods.
From the docs: http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html
viewWillAppear: Notifies the view controller that its view is about to
be become visible.
(void)viewWillAppear:(BOOL)animated Parameters animated If YES, the
view is being added to the window using an animation. Discussion This
method is called before the receiver’s view is about to be displayed
onscreen and before any animations are configured for showing the
view. You can override this method to perform custom tasks associated
with presenting the view. For example, you might use this method to
change the orientation or style of the status bar to coordinate with
the orientation or style of the view being presented. If you override
this method, you must call super at some point in your implementation.
For more information about the how views are added to windows, and the
sequence of messages that occur, see the information on presenting a
view controller’s view in “Custom View Controllers” in View Controller
Programming Guide for iOS
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to tell when back button is pressed in a UINavigationControllerStack
When I press the back button, what Delegate method is called?
UINavigationBarDelegate is the delegate class and it implements -navigationBar:shouldPopItem, since these controllers work in stacks you're just pushing or popping views. This will most likely always evaluate to true otherwise I feel a back button that does anything but pop a view controller will violate Apple's Human Interface Guidelines.
I agree with elsurudo, the - (void)viewWillDisappear also gets called when you go to a third ViewController, but maybe you want your connection to exist in the Third View Controller but not in the First View Controller. So you might want to detect when the user goes back from the Second View Controller so you can disconnect properly.