view not showing - iphone

Greetings guys,
I am a newbie in iphone programming. Basically my problem is the following:
I have a view which have inside an info button and a UIScrollView and inside this scrollview I have programatically added buttons with images.
When I press the info button the next view shows up, however when I press a button from scrollview nothing happens knowing that it is catching the click and it is accessing the function that is responsible for showing the next view.
- (void)showFlipid)sender{
FlipsideViewController *controller = initWithNibName:#"FlipsideView" bundle:nil];
controller.delegate = self;
NSlog(#"1"); // IT IS SHOWING WHEN I PRESS A BUTTON FROM UISCRoll
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
}
Please help

It seems that your code is missing critical line.
Try to add :
[self presentModalViewController:navigation animated:YES];
at the end of your code.
BTW
you should release the controller at the end.

Related

Form Sheet Modal View Animations

I have UIModalPresentationFormSheet views appearing in my app. Some of them appear from the Right some from the Bottom and the dismissing seems random. Some disappear to the Bottom some go Left some go Up. Is there a way to set the direction they appear from and dismiss to?
Code I use to present (this same code, just different viewcontroller being presented, called from the same view controller has varying animations for different modal views):
MyViewController *newModalView = [[MyViewController alloc] init];
newModalView.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:newModalView animated:YES];
Then in the modal view I call this to dismiss it:
[self dismissModalViewControllerAnimated:YES];
This is a known bug and is being worked on by apple.
Try something like this:
newModalView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
All the transition Styles:
newModalView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
newModalView.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
newModalView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

Presenting ViewControllers Modally

I am Making a word game and I need some help with the navigation. This game starts in a menu, from that menu you can click 'create game' which would open the 'GameViewController'. in this GameViewController you can submit a word when it's the right word There Pop ups a screen which is 'RightWordViewController' When it's wrong it pop ups 'WrongwordViewController' in both right and wrong there is a button which would go back to the game.
In the GameViewController there is also a menu button which works perfectly except for after you have submitted a word. If you would click the menu button in a GameViewController when you already had submitted a right or wrong word the menu button would bring me back to the right or wrong view controller. I Understand why this is happening,I just don't know how to fix it. I use dismissModalViewcontroller which shows me the view behind the current, and that is Right or Wrong Viewcontroller I need to fix this and hope someone can help me.
To go from menu to game
-(IBAction)switchview:(id)sender {
GameViewController *game = [[GameViewController alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:game animated:YES];
the menu button that goes from the GameViewcontroller to the main view (menu) (it dismiss the current screen so when I have submitted a word right or wrong those screens pop up and when I would click this button right or wrong would show up again.. what I don't want ofc.)
-(IBAction)switchback:(id)sender {[self dismissModalViewControllerAnimated:YES];
to go either right or wrong I use:
if ([labelsText.text isEqualToString: textview.text]){
RightWordViewController *Rightword = [[RightWordViewController alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:RightWord animated:YES];
}
else
{ WrongWordViewController *Wrongword = [[WrongWordViewController alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:WrongWord animated:YES];
}
And then for Going back to the game screen when Im in Right or Wrong view controller
-(IBAction)switchback3:(id)sender {
GameViewController *game = [[GameViewController alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:game animated:YES];
I hope someone can give me some really clear explanation or some sample code.
In the switchback3: method you don't need to preset the viewcontroller again.. just dismiss the one thats in the front..
[self dismissModalViewControllerAnimated:YES];
also, add a boolean in gameview controller to set a status to check whether to show/not show the right/wrong view.
Use
-(IBAction)switchback3:(id)sender {
[self dismissModalViewControllerAnimated:YES];
Reset your submitted words before presenting the right/wrong view controller.If you are presenting a view and u need to go back,use dismissModalViewController.No need to present that view again.

displaying navigation bar when switching to another view

I have a button when it pressed, I want it to take me to another view (the "news" view). Within the news view, I want there to be a navigation bar with a back button. I have a navigationcontroller setup throughout my app but I can't seem to get this to work when this button is pressed. It takes me to the view I want but there is no navigation bar and no back button. This is my code that is implemented when the button is pressed.
If anybody know what I am doing wrong, it would be much appreciated.
Thanks
-(IBAction)news
{
newsViewController *view1 = [[newsViewController alloc] initWithNibName:#"newsViewController" bundle:nil];
view1.title=#"news";
[self.navigationController pushViewController:view1 animated:YES];
}
I am not in my mac, so I can not test code, but if it is working and the only issue you got is not show the bar, what you need to is set the bar to be visible:
From apple docs:
The navigation toolbar is hidden by default but you can show it for
your navigation interface by calling the setToolbarHidden:animated:
method of your navigation controller object. If not all of your view
controllers support toolbar items, your delegate object can call this
method to toggle the visibility of the toolbar during subsequent push
and pop operations.
Something like that is supposed to work:
-(IBAction)news {
newsViewController *view1 = [[newsViewController alloc] initWithNibName: #"newsViewController" bundle:nil];
view1.title=#"news";
[self.navigationController pushViewController:view1 animated:YES];
//Add this line!
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
I hope it can help you.
write the below code in page where you want to show navigation controller
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.navigationController.navigationBarHidden = NO;
}

Presentmodalviewcontroller causes mkmapview to disappear

Hitting my head against a wall here. Feel like this should be simple, but just can't figure it out.
I have a Window with a UIViewController set as its rootviewcontroller. In the rootviewcontroller, I have a full screen mkmapview. Catch is, when presentmodalviewcontroller gets called, I see my mkmapview completely disappear (the color of my viewcontroller's view underneath instantly comes up) just as the new screen comes flying in. Once I dismissModalViewControllerAnimated, it goes back to a (black) screen.
I've tested this a bit by removing the iboutlet of the mapview in IB - then the transitions work like a charm.
I don't think it's this code as I'm using the template Utility app as a guide - but just to give some substance:
-(IBAction)settingsGearPressed:(id)sender
{
SettingsViewController *controller = [[SettingsViewController alloc] initWithNibName:#"SettingsViewController" bundle:nil];
controller.delegate = self;
controller.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:controller animated:YES];
}
Basically I was removing the mapview in ViewWillDissapear

How to add a 2nd view as a Tab Bar View (iPhone SDK)

So before I've managed to work with TabBarViewControllers and create an application using them. However every time I do so the view acts as my main view. This time around I want my TabBarView to be my second view in my application
E.g
First window has a bunch of buttons, when I click one of these buttons I want the second view to show up. This view includes a TabBarViewController.
The farthest I've gotten is to have the button show a view but for some reason it won't show my TabBar view!
Here's the code for my button
- (IBAction)showEvents:(id)sender {
EventsViewController *controller = [[EventsViewController alloc] initWithNibName:#"EventsView" bundle:nil];
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
}
Any of you guys able to help?
Can't you just in the EventsViewController add the following code in viewDidLoad:
UITabBarController *tbc = [[UITabBarController alloc] init];
tbc.viewControllers = [NSArray arrayWithObjects: vc1, vc2, ..., nil];
Anyway, I found a solution and it was actually quite simple. After creating the Outlet for the TabBarController and linking it together with File's Owner all I had to do was add
self.view = tabViewController.view;
On the viewDidLoad method