I'm running SDK 3.2.3 I have a simple tab bar controller with three view controllers. Each view controller has an NSArray of images for a simple animation. The animation runs a loop when each of the tabs is pushed however if you go back to tab one after you've pressed another tab, the animation doesn't run again. Any code I could put in here to have it run again and again? help would be much appreciated.
You should consider to stop your animation on the viewWillDissappear method and start it again in the viewWillAppear.
Anyway, if you dont paste ypur code is very difficult to help you
Related
I am new at ios programming and I need some help, can't figure out how I am going to switch between two views without firing a button event
I have a splash screen waits for 2 sec then it should go to main view. I don't know how I am going to acquire the main view's reference and navigate to main view!
Any tutorial about switching between views programmatically?
Thanks for your help.
Cheers
For Splash screen you have to name it Default.png and in appDelegate didFinishlaunchingMethod, you have to add view controller to window. the Default.png is automatically reference as a splash screen. try it out
Start with one of Xcodes default projects, and see how they are setup. They should give you a window, with a main view out of the box.
If you add a Default.png image file to your project, it will automatically be used as a splash screen and displayed upon startup. However it will not be visible for 2 seconds, but rather as long as it takes for the application to start.
If you want it to be displayed longer, you will have to add a UIImageView with the same png image to your mainview, then remove this from your mainview after two seconds.
You can use performSelector:withObject:afterDelay to trigger the hiding of the UIImageView after a period of time. However this goes against Apples design guide, as the splash screen only is meant as a ting for the user to look upon before the application launches.
As for adding new views, I recommend using a UINavigationViewController. Using this enables you to navigate back to the main view, and you also get a nice animation as a transition between the views.
If you want to switch between views you use addSubview
maybe this tutorial will help ->Tutorial
I'm trying to build an educational app that will have approximately 3-5 completely different pages/screens. Each screen contains one puzzle and each puzzle is independent of all the other puzzles (screens). Once the puzzle on the current screen is solved I'd like to transition to a new (randomly selected) screen. I would allow the same puzzle to be shown multiple times, however, if it had been displayed before it would need to be reset.
I've tried doing this using segues but that seems to require a UINavigationController which is not the experience I want to present (since it requires a predefined hierarchy of screens).
I assume the best way to do this is to have each screen as completely separate UIViewControllers, correct? I'm just not sure how to orchestrate the navigation/rendering between them.
I'd appreciate whatever best practices you know of. Thanks!
Well here is a possible option:
First of all if you want a menu outside of these puzzles have that as your root view controller in a UINavigationController.
Then create a launcher controller and add it to the navigation controller when appropriate. This will be a regular UIViewController except in this controller in the viewWillAppear method have it pick a random number 0-5 and run it through a switch and depending on the number push one of your 5 view controllers. Then when the puzzle is completed call popViewController on the navigation controller. Now when it pops back, viewWillAppear will be called again and randomly push another. Then if you want to go back to the main menu at any time just call popToRootViewControllerAnimated. This should do what you need. And to make it so it doesn't animate twice either only have the push animate or only the pop.
Rather than having different view controllers you can have a single controller. You can reload the view of the puzzle after completing the first. The logic you have applied for the first puzzle will be some what similar to the the others. So now only you need to handle different states of the puzzle.
For example: I have first view with puzzle 3x3 matrix, the next will be 4x4 matrix and the next will be 5x5 matrix. So this states needs to be handled through code in view controller.
I know that using cocos2d is a great way to build games and it allows different "scenes" where things are independent of each other or can communicate if you choose. Also with cocos2d there is a "director" that handles all of the scenes and can push scenes for you. If you are curious check out: www.cocos2d-iphone.org
I hope this helps :)
Well, I was build the app tested yesterday to play different music instrument. I use UIView to handle view for 3 of my instrument. The logic is simple. I put the navigation on UIButton and add a subview for each instrument. When the user touch the button, the selected view will be add to the front, and the last view will be release or temporary on the background.
Hope it will help you.
Im officially getting annoyed with objective-c and xcode now. Programming in PHP and Java is so much easier haha.
Anyway I could do with some help.
I have created a tab bar application with three tab items for the iPhone, on one of the items it loads a nib named mapView, this contains a button that I want to use to load up another nib named OverlayViewController.
Ive been following this tutorial this tutorial
to create a camera overlay. I understand how it works, but I don't understand how to run the view controller from a button or direct from the tab bar. I can only get the overlay to work if I load it like in the example on application launch in the app delegate. If I try and load it from the tab bar item I just get a grey screen, looks like the blank view controller is loaded and the code hasnt been run to show the overlay.
If anyone can suggest how I would go about loading the overlay from the button click, or even direct from the tab bar item I would be really grateful.
Thanks Alex
p.s. Heres the link to the project if you wish to view the files
#AlexApps I took a look through your project and have several pieces of feedback.
I think before you get too into trying to get the OverlayViewController working you should back up a bit and give some of the Apple docs a read, especially the View Controller Programming Guide. The Apple docs are for the most part well written and should help you gain a better understanding of views and view controllers than what is evident in your code.
Another suggestion is to grab some of the freely available source code from a book such as Beginning iPhone Programming which has a good example of how to lay out a tabBarController based app. I am sure there are other good samples out there that will show you how to organize your views and view controllers to load them into the different tabs.
I think that if you follow this advice that by the time you have restructured your app by what you learn you will have less problem doing what you are trying to do.
BTW, you may want to consider using a NavigationViewController for what you are trying to do with loading the OverlayViewController with a button press but take a few hours, slow down and do some focused reading. It will make a world of difference. Then if you have more specific questions, Stack Overflow (and Google) are your friends.
One last tip, you do not need to put IBOutlet in your instance variables AND in your properties, just one or the other, and really, you don't even need the instance variables at all anymore. I usually just use properties for everything.
I have done it with storyboard and the solution is to create a segue between the tab bar view controller and the view controller you want to load, then you have to put an identifier to that segue. Finally, in the method called when the button is pressed you have to put this:
[self performSegueWithIdentifier:#"segueId" sender:sender];
I have done it right now and it works perfect!
First import uiviewcontroller class in frist page like below:
#import "page2viewcontroller.h"
on button click event code below:
page2viewcontroller *page2 =[page2viewcontroller alloc] ;
[self presentModalViewController:page2 animated:NO];
[page2 release];
after back page2viewcontroller to page1viewcontroller same as like below:
#import "page1viewcontroller.h"
on backbutton click event code below:
page1viewcontroller *page1 =[page2viewcontroller alloc] ;
[self presentModalViewController:page1 animated:NO];
[page1 release];
That's all....!
I tap a tab bar item, which triggers poptoRootViewControllerAnimated. Most of the time it works as expected, but in some cases it pops to the correct view, but the navigation item is out of sync, "stuck" from the view i previously was at.
I've read about people having this problem with iPad's, when in landscape mode, but the solutions I've found don't work in this case. This is an iPhone app in portrait mode.
Happens with the simulator as well as on an actual iPhone. If someone has a suggestion or solution i'll be a very happy man!
Turns out that the different iOS versions handle this differently. This only occured on the older versions, so we had to rebuild the stack manually there.
do you get any message in the console like
nested push animation can result in
corrupted navigation bar
and
Finishing up a navigation transition
in an unexpected state. Navigation Bar
subview tree might get corrupted.
if yes take a look at these few answers...
but what they all basically mean is you are trying to pop from the navigation controller too early, probably before it is properly loaded...
I am using a UITabBarController with 3 items and am curious how to access a method from the first tab if I am on the second or third tab. The problem I am running into is I have a UIImageView on the first tab that is using core animation to loop continuously through 3 images. But when I switch to the second tab and try to switch back to the first tab the program hangs. I discovered if I stop the animation then it will let me switch back to the first tab fine. Any ideas?
You can access view controllers in UITabBarController using its viewControllers property (returns array of controllers) and get the one you need by its index.
The better way, however, is to try to stop animations in controller's -viewWillDisappear: method and resume animations in -viewWillAppear: .