UIActivityindicator won't be displayed upon Modalviewcontroller - iphone

i've created a login screen via a modalviewcontroller. But certainly i have a problem to display a uiactivityindicator once the loginbutton was pressed.
Instead the activityindicator seem to be displayed for a minimal period of time, when releasing the modalviewcontroller.
Does anyone know the problem.
Could anybody help me out?
Thanks a lot.
Greetz

I've got the solution.
Apple seems to combine animations. So the animation of dismissng the modalview and startanimating function of the uiactivityindicator are combined to one action
and the animation of the activityindicator will be never shown.
Simple hack:
Just wait with the dismissal of the modalview for a short time e.g.
[self performSelector:#selector(hideLogin) withObject:nil afterDelay:0.1];

Related

viewcontroller won't dismiss

I have the following code
- (void) viewWillAppear:(BOOL)animated
{
NSLog(#"dismiss view");
[self dismissModalViewControllerAnimated:YES];
}
This prints dismiss view but won't execute the view dismissal code.
Can a view be dismissed in code without a trigger from an IBAction?
Why wouldn't this be executing?
You would probably have better luck putting the code into viewDidAppear rather than viewWillAppear. The latter tends to be called right at the start of any animation such as a modal beginning to slide off the screen; the former tends to be called when that animation has completely finished. Note that even if this strategy works, you may end up with a weird effect whereby two modals are seen to slide off, one after the other; I presume you just want one sliding off effect.
What happens if you dismiss the "lower down" modal dialog (the one first pushed), and don't bother dismissing the one that is topmost?
Also consider paying attention to the animated argument when dismissing your modal view controller. Different combinations of animated or not can have different effects when you have problems like yours.
If you post a more complete code sample we can give a better answer!
try with a little delay on the second dismiss.
- (void) viewWillAppear:(BOOL)animated
{
NSLog(#"dismiss view");
[self performSelector:#selector(delayedDismiss) withObject:nil afterDelay:0.5];
}
-(void)delayedDismiss{
[self dismissModalViewControllerAnimated:YES];
}

Retrieving score value when using presentModalViewController to switch views in xcode

I face this problem of retrieving a game "highscore" after someone finishes a game.
What I did was this:
I call presentModalViewController method when time reaches 0.
GameEndingViewController *gameEndingView = [[GameEndingViewController alloc] initWithNibName:#"GameEndingViewController" bundle:nil];
gameEndingView.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:gameEndingView animated:YES];
[gameEndingView release];
I want to show the score that I attained in the main gameloop in this gameEndingView that I have. However, it seems that when I use presentModalViewController method to switch view. The variable, score, that I update during the gameloop gets reseted. My whole game loop is in a view gameMainView.
Could someone explain to me about the use of presentModalViewController and how should I better solve my problem?
Thank you very much.
This is not the problem with your modal view. You have a problem in the app logic. You should better check this out again.
The good idea would be declaring the score as the property and set a breakpoint so you could see where it is changed.

presentModalViewController does not work if called too early

If I dismiss the the modal VC and present it (or another one) again in less than a certain amount of time, it does not appear.
Am I missing something?
Yes, you can't do that. I'm assuming what you did is something like this:
[self dismissModalViewControllerAnimated:YES];
[self presentModalViewController:myNewController animated:YES];
This doesn't work. I don't know exactly why, but it is related to the animations I believe. Your options are to either dismiss the first one without animation, or else wait to present the new one in viewDidAppear of the parent, (or possibly viewDidDisappear for the previous modal view, not sure if that works though).
You cant dismiss two modal view controllers right after another, aside from what the other poster suggested, you can wait a small amount of time before dismissing the other modal view, for example
[self performSelector:#selector(method) withObject:nil afterDelay:.5];
where the method called just dismisses your other modal view.
The snippet of code performs the selector after .5 seconds and can be used when having animation timing problems like the one you describe, to seperate the call times in order for them to execute properly.

How can I create some view over UIKeyBoard?

I fill information then tap "Done" button for doing some process and show loading view for waiting.
I need loading view is over every view, but How can I do?
Thanks for adviser.
Here is my image (I'm new in here, so I can't post image)
http://www.freeimagehosting.net/image.php?62e2584aea.png
You should make your keyboard disappear from the screen as soon as user taps on done button.
call this method
[myTextField resignFirstResponder]
when you start loading
this is the best answer for your question
[textField setInputAccessoryView:inputAccessoryView];
Did you observe the UIKeyboardWillShowNotification and UIKeyboardDidShowNotification notifications? You can update the view elements in the handlers.
Try to add the loading HUDView ro whatever you are using for the purpose on the application's keywindow.
as
[[UIApplication sharedApplication].keyWindow addSubview:loadingView];
ALso resigning the responder while the loadingview is displayed is really a very important thing you should do.
[myTextField resignFirstResponder]

I would like to flip my app's splash screen - how can I mimic the flipside controller's animation?

I've finally gotten a working "alpha" version of my first app installed and (mostly) working on my iPhone 3G. So excited I came into the house and danced a little jig while my wife rolled her eyes at me. Don't care - totally stoked that I figured it out on my own (with lots of help here - thanks again, guys).
I've never really dabbled with or cared about animation; I'm more into utility-type apps. However, I've decided that I'd like to animate my app's opening image / default.png / splash screen similar to the flipside view controller animation - where the image spins from a view on the front to a different view on the back. I've found code for animating between views using the flipside animation, but how would I go about animating from a static *.png image to my navigation-based table view? I'm just not even sure where to start with this one - literally the first time I've ever even searched for anything graphics-related in the documentation.
Any help will be appreciated. As usual, thanks in advance!
You can't do anything with your Default.png, and just for form I'll point out that that HIG guidelines say that you shouldn't use it as a splash screen :-).
I would suggest that you use your initial view controller to duplicate the Default.png, and copy the flip animation code from a basic Utility app template - you probably want to use [NSObject performSelector:#selector(...) afterDelay:0] to get it to flip, called from your initial viewDidLoad:.
You can just present a modal view controller when you first launch using the flip transition instead of the default slide. Have your initial view controller loaded from your xib just display the same image you are using for your Default.png. Once you get the -viewDidLoad call in your initial view controller, push the modal view specifying the transition you want. Something like this:
- (void)showMainView;
{
MainViewController *controller = [[MainViewController alloc] init];
[controller setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentModalViewController:controller animated:YES];
[controller release], controller = nil;
}
As Paul suggested, you should call this using performSelector:withObject:afterDelay:
[self performSelector:#selector(showMainView) withObject:nil afterDelay:0.15];
Hope that helps.