What are some methods to know when a MainScreen will appear? - view

I'm working on a blackberry application with navigation through multiple screens. Is there a way to know when a MainScreen becomes visible like the viewWillAppear method in iOS when I pop one MainScreen and go to a MainScreen that already exists on the view stack?.

you can override protected void onExposed() in your main screen class and it will be invoked when this screen is revealed by a screen getting popped off the display stack.

Related

What happens in the OnAppearing of Xamarin Forms?

I have a Forms application which works good but I notice the background colors appear set incorrectly for a fraction of a second as the page appears.
I have this code for my OnAppearing
protected override async void OnAppearing()
{
base.OnAppearing();
Subscribe();
vm.Theme = Settings.th.ToString();
await SetCardButtons(Settings.cc.Text());
}
Can someone explain what happens in the base.OnAppearing() and should this be the first or last line in my override?
what happens in the base.OnAppearing()
OnAppearing is a virtual method in the Page base class, that does not contain any code (but that does not mean it does not do anything).
Depending upon which Page subclass you are using, different things might be performed, like the MasterDetailPage performs logic to determine if it should be displayed as a splitview (side-by-side) mode, the native iOS code would do this on an iPad, ....
should this be the first or last line in my override?
Normally this would be called first in your override to allow any custom subclass code to setup the UI properly.

adding delegate to responder chain stops scrolling from working

For a number of reasons, I have added my class that implements NSOutlineViewDelegate protocol to the responder chain:
[myOutlineView setNextResponder:self];
This stops my outline view from scrolling. Take the call out - scrolling works fine, put it back - scrolling stops. If I use the up and down arrows to move the selection through the view it scrolls to show the selected row OK, but gesture scrolling doesn't do anything.
The delegate contains quite a few methods for supporting drag and drop, and ibaction methods for supporting context menus, but I can't think what is in there that would interfere with scrolling (I am using a macbook air with gesture scrolling). Anyone got any ideas what is causing the interference? or any ideas how to diagnose?
I should add that I made the delegate class a subclass of NSResponder.
So the answer is, when adding a delegate into the responder chain, you must also add to the delegate the responder that used to be in its place - otherwise the chain gets broken and the events don't get handled, so it goes:
NSResponder *nextResponder = myOutlineView.nextResponder;
[myOutlineView setNextResponder:self];
[self setNextResponder:nextResponder];
With the responder chain restored, my outline view now scrolls again. Hooray

Why I can't ctrl - drag a button in the interface file?

I have this view controller:
It's a UITableViewController with static cells.
This is the structure of all screen: the table with static cells and two views(one up one down)
My issue is that I cannot Ctrl-Drag anything from this screen.
What is happening?
You've probably forgot to set the custom class of your controller in IB
Also a quick change to 'Automatic' mode in the Assistant Editor should show the respective files, if it doesn't then you know that probably IB doesn't have a clue about your subclass and that's why it prevents the connections.

Monotouch addsubview animation

I have my navigation controller and my view controller. I can't seem to get a simple transition between those views when I push a button in the navigation bar. It now just pops up.
When I push the button in the navigation controller, it calls the code below in the main file.
public void GoToViewController()
{
window.AddSubview(theViewController.View);
}
I have been calling:
UIView.SetAnimationTransition(UIViewAnimationTransition.None, spct.View, true);
which works, but I would like to let this view simple appear from the right, over the other view (just like the navigation controller does with its views).
You should just use UINavigationController.
Making the transition should be fairly easy, and is worth it over trying to recreate what Apple has already built.
For each of your view controllers, you should be able to change their base class to UINavigationController--or just change their type to UINavigationController if you did not subclass them. After that, you should just have to replace your custom transition code to use PushViewController(), PopViewControllerAnimated(), etc.
Using UINavigationController is fairly simple in general.

I Can't See the Highlighted State of My Custom When I Push it To Get a New View

I am reading many posts about UIViewController managing but I can't find the solution to my problem. I am making an iPhone game. I have three screens (menu, game play and scores) constructed into the Interface Builder and from three UIViewController classes. Into the main menu I have two custom buttons that allow to go to the game play screen or to the scores screen. Actually I am using the next method to navigate but when I use it, even it changes the screen and takes me to the game play, I can't see the highlighted state of the custom button. Must I change the views like this? How can I show the custom state of my buttons? How can I show an animation while the views are changing?
- (IBAction)gotoPlayViewController:(id)sender {
//Navigation logic may go here.
PlayViewController *playViewController = [[PlayViewController alloc] initWithNibName:#"PlayViewController" bundle:nil];
self.view = playViewController.view;
[playViewController release];
}
Thanks for readding.
You want to use UINavigationController, don't you?
The UINavigationController class implements a specialized view controller that manages the navigation of hierarchical content. This class is not intended for subclassing. Instead, you use instances of it as-is in situations where you want your application’s user interface to reflect the hierarchical nature of your content. This navigation interface makes it possible to present your data efficiently and also makes it easier for the user to navigate that content.
Here is a nice tutorial.
Here is the class reference.
UINavigationController also provides a very easy way to add the slide transition you want.
Have fun!

Resources