Here's The probem.
I have an iPhone app that needs to have 2 splash screens.
the first splashscreen will show for 1 or 2 second before it fading out and changing to the second splash screen and in the second splash screen it has [x]close button in the top right corner which similiar to windows close button.
and it has an action to close the second splash screen and go to the main window.
i already try to make it with variety of ways, but i'm not even close to the goal.
and maybe it's because i'm totally new in iphone apps development.
so guys, i really need your help..
If I interpret your request correctly, you can accomplish this by triggering a segue from your app delegate. Say, for example, that you want to do the following after app launch:
Show View A for 2 seconds
Fade to View B
Have user tap [x] close button to reveal View C
You can something similar to the following if you are using Storyboards:
Configure an initial view controller MYAViewController. Add MYBViewController. Add MYCViewController.
Then set an outgoing segue from MYAViewController to MYBViewController. Select this segue and from the Attributes inspector, give it an Identifier of AToB, set its style to Modal, set its transition to Cross Dissolve and ensure that Animates is selected.
Add another segue from MYBViewController to MYCViewController. Select this segue and configure however you want to, but give it has an identifier of BToC.
Then from your app delegate, trigger the segues programmatically.
In MYAppDelegate:
...
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self performSelector:#selector(showViewB)
withObject:nil
afterDelay:2.0]; // seconds
}
- (void)showViewB {
[self.window.rootViewController performSegueWithIdentifier:#"AToB"
sender:self.window.rootViewController];
}
...
Note that all view controller names and segue identifiers are contrived. Obviously, you would want to name these items in a way that is meaningful to your application.
Hope this helps.
Related
So I have an iPhone app. It has a simple structure, all based on a UINavigationController.
I have a storyboard that has one view, a segue to another view, etc. Now this other view has a UITextView that I do not want to edit on this screen - if the user taps this, I want it instead to fly over to a second screen which basically has the same text view, but this one is full-screen, and the user will edit the text on that screen before returning to the previous screen.
So I capture the textViewShouldBeginEditing method. I previously, in the storyboard editor, manually created a push segue from the previous view controller to this new view controller, and named it so that I can call it by it's identity, which I do with:
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
{
// This is called when the user clicks into the textView as if to edit it.
// Instead of editing it, go to this other view here:
[self performSegueWithIdentifier:#"editMemoSegue" sender:self];
// Return NO, as I don't actually want to edit the text on this screen:
return NO;
}
Seems reasonable. And it works. Sorta. It does in fact shoot me over to that other view. That other view's events fire up, I set it's text view to become first responder, I edit the text on that screen. Everyone's happy.
Until I want to use the back button to return to the previous view.
Then I quickly find out - my navigation stack is foobared. Most of the time, I have, for some reason, TWO instances of my new editing controller on the stack, so the first time I hit the back button I get the same stuff over again. Then, oddly, occasionally, it will work as intended, and I will see my previous controller with only one back click.
I started reading the log, and I found this:
2012-12-09 09:41:03.463 APP[8368:c07] nested push animation can result in corrupted navigation bar
2012-12-09 09:41:03.818 APP[8368:c07] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
2012-12-09 09:41:03.819 APP[8368:c07] Unbalanced calls to begin/end appearance transitions for <SecondController: 0x83881d0>.
So obviously, I'm doing something incorrectly here. The question is, what? And how do I do what I want in the way that correctly appeases the tiki gods of the iPhone framework?
Check to see if the textViewShouldBeginEditing is being called twice. I've noticed that these kinds of delegate calls sometimes are.
How is your #"editMemoSegue" being created on the storyboard? is it created from the textView? if it is then you should recreate it directly from the view controller or from the top status bar on the view controller that way it wont be called twice when you touch the trigger object and when you call it programmatically.
I am new to iphone programming and I have created a special scenario. I am pretty sure that it will answer most of my questions for creating my app. Here it is. (i HAVE Xcode 4.2)
I have created a universal application with storyboard and single view.
I have appDelegate, storyboard files and a class file ViewController.h/m for my initial ViewController.
Suppose I have added a progress View (Graphically) on the view Controller. Also I have added another viewController on storyboard and made its background black.
When i run the app my first viewController with progress view shows up
Now my questions are
1- How can I link my progress view in the class file and how can i set it progress for 5 seconds.
2- After showing progress within 5 seconds it should switch to other view Controller with black background.
3- I have created a class file "MySecondController" How can i link this class to my black screen viewController.
These are easy questions. I hope I get answer to these. If anyone have tutorials linking to these questions do post. I have tried and haven't found useful.
Best Regards
1a) On the upper right of the xcode window, there's a tuxedo icon. This is the assistant editor. Select the storyboard, select the ViewController, then select the assistant editor. A second editor will appear. Make sure it's editing ViewController.h. Press control and drag from the progress view in the storyboard to a point inside the ViewController interface definition. (right after the line that looks like this: #interface ViewController : UIViewController) You'll be prompted to type an outlet name. Type something like "progressView" (no quotes).
1b) See below to set the progress view to a value.
2) See below to present the second view controller after a delay.
3) In the storyboard, drag a new viewcontroller onto the canvas. On the identity inspector (try the icons under the tuxedo icon, the third from the left is identity), set it's class to MySecondController. Select the original ViewController, press control and drag from it's status bar (the top of it) to the viewcontroller you just added. This will create a segue. A menu will appear asking what kind of segue you want. Make the segue modal for now. Click on the new segue to select it, then click on the attributes inspector (right next to identity inspector) give the segue an identifier, call it "MySecondControllerSegue".
Back to questions 1b and 2) Go to ViewController.m and add this code...
#synthesize progressView;
// this creates methods on self to access the progress view
// this is called after the view appears
- (void)viewDidAppear:(BOOL)animated {
// do inherited behavior
[super viewDidAppear:animated];
// set the progress view value to a number between 0.0-1.0, representing percentage
// notice how we used the synthesized getter: self.progressView
self.progressView.progress = 0.5;
// call another method with no parameters after five seconds
[self performSelector:#selector(doSegue) withObject:nil afterDelay:5.0];
}
- (void)doSegue {
// run the segue that you created in IB
[self performSegueWithIdentifier:#"MySecondControllerSegue" sender:self];
}
Build and run.
After this is working, you'll probably want to show that progress view advancing from the 0.0 position to 1.0 over the course of five seconds. For that, you'll need to read about NSTimer. You can set one up to send you a message periodically, and you can adjust the progressView each time.
I am creating a project with Xcode 4.2 and using it's storyboard. In one of the views I have a button that a user will tap and it will perform some calculations. If the calculations are correct I need to display the view that they just came from. I am currently using a Navigation Controller. When the app starts it loads View 1. When I choose an option it loads View 2. If I click the 'back' button in the toolbar it loads View 1 with left animation.
In my IBAction method for the View 2 calculation I have the following snippet.
[self performSegueWithIdentifier:#"BackToView1" sender:sender];
But the problem is it loads View 1 using the left animation when I need it to load the right.
Would that be a custom segue? Am I missing something?
[Edit]
I just noticed something as well. When View 1 loads from my IBAction it appears it is initializing the AppDelegate again, whereas the 'back' button does not. I need to not initialize the AppDelegate since I am loading a data object at the start of the app. Calling init again kills my object.
You could try using the navigation controller to pop back. This will probably produce the effect you are after.
[self.navigationController popViewControllerAnimated:YES];
I am making code for iPhone. My first screen has only one button with text Menu. When user will click on this button next screen is coming with multiple navigation bar.Each Navigation bar has their own Text information which are being selected after clicking on any Navigation bar.
How i should to design it for iPhone ? Please give me concept. Should i take multiple views ? If i have multiple views how will i hide and show on button click event ?
Thanks in advance.
You will have to adapt your user interface to comply to how Apple wants an app to work, look, and feel - or make your own custom viewcontrollers. Even then, you might not get the exact behavior you want.
My hottest tip is to look at similar apps on appstore and see how they are navigated.
I don't get a picture in my mind from your description, but it seems you want what is called "drill down". This is best done with tableViews.
You can't have multiple navigation controllers on the same "screen"; it doesn't work like that on the iPhone. Instead, what you have is one single Navigation controller, that controls the pushing of views. You decide which sub-view to push depending on which selection the user makes, and the Navigation controller handles the rest of the interaction with the user to let him or her navigate between the views.
Example structure:
Window-based app
+-MainWindow.xib
| +-First view with button
| +-UINavigationController
+-tableview1.xib
+-tableview2.xib
+-any more views you need.
Make the app delegate a <UINavigationControllerDelegate> and declare navCt *UINavigationController, and connect it in Interface Builder. You can then write a pushVC method, which takes as argument a UIViewController *vc. It does a [navCt pushViewController:vc animated:YES];
Connect the button to an IBAction, which then calls the method in the app delegate, [PushVC myVC], where myVC refers to any viewcontroller in your app, in this case table view 1.
In this table, on didSelectRow... event you can use the same method to push the sub-view table view 2.
I think this is minimum code if you are unsure about iPhone app design. Either way, I hope it gives some ideas.
You should read about UINavigationController, UITabBarController, UIViewController.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html
You almost always make one view pr. viewcontroller.
My application is pretty simple: it starts up with a view controller that holds a table view (in grouped view layout) with a few options. When the user taps on one of the options, I push another view controller onto my navigation controller.
This second view controller simply displays a UIImageView, and the user can change the screen orientation on this view controller between portrait/landscape modes. This works just fine, and all is happy.
However, if the user taps on the "Back" button on my navigation bar while on the landscape mode, the first controller's layout is all messed up. See below for before/after screenshots:
(source: pessoal.org)
(source: pessoal.org)
Any clues on how to force the first view controller (second screenshot in this post) to stay within the portrait screen orientation?
There does not appear to be a way to do this using the documented methods.
I have filed a bug for this: rdar://6399924
"There is no way to always restrict a UIViewController to one orientation"
You can see it on open radar (along with a link to sample code to reproduce the problem) here: http://openradar.appspot.com/radar?id=697
Like someone on the open radar suggested, a workaround is to disable "back" button while in non-portrait:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
// don't let user press "back" button in landscape - otherwise previous view and the rest of the application
// will also be in landscape which we did not feel like testing yet
self.navigationController.navigationBarHidden = (UIInterfaceOrientationPortrait != self.interfaceOrientation);
}
There is a solution to do that : it's to use a view controller and adding its view to the window. then in that controller you force landscape in the shouldAutorotate... methode. It works fine, but be sure it's necessary for your project to use that, because it's not very smart to force the user to turn his iPhone. By the way, here is an example code if you need it.
http://www.geckogeek.fr/iphone-forcer-le-mode-landscape-ou-portrait-en-cours-dexecution.html
I wasn't able to get this to work the way I wanted. You ought to be able to set a particular orientation for a ViewController, but the NavigationController doesn't seem to always do the right thing.
I ennded up re-designing my screens so that they all work in either orientation. That might be extra work, but it "feels" more natural, anyway.