Flip View for 2.2.1 iPhone SDk - iphone

I have an App that works great in 3.1.2, yet when I revert to 2.2.1 my method to flip the view doesn't work, using the following code:
-(IBAction)infoButtonPressed:(id)sender
{
SecondViewController *second = [[SecondViewController alloc] initWithNibName: nil bundle:nil];
second.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:second animated:YES];
}
I get the following error (http://screencast.com/t/YTJlYTgz). Thoughts on how I can fix this easily?

modalTransitionStyle is only available for 3.0+. If you want to have a similar transition you will have to create the animation transition yourself. Take a look at the following UIView function
+ (void)setAnimationTransition:(UIViewAnimationTransition)transition forView:(UIView *)view cache:(BOOL)cache

Related

AQGridView - Orientation change in ExpanderDemo

I just started checking AQGridView and new to iOS too in the source example ExpanderDemo the orientation is working fine for the first View but as i click any cell and next upcomming AQGridView does not effect View on GridView.
ExpandingGridViewController *controller = [[ExpandingGridViewController alloc] init];
controller.gridView.frame = self.gridView.frame;
[self.gridView setHidden:YES];
[self.view.superview addSubview: controller.gridView];
[controller expandCellsFromRect: expandFromRect ofView: cell];
[controller viewDidAppear: NO];
On the other hand if i present the view controller to second it works fine with the orientation but losses the Animation for Expansion; which i don't want to loose. What should i do?
ExpandingGridViewController *controller = [[ExpandingGridViewController alloc] init];
[self presentViewController:controller animated:NO completion:nil];
The last time I use AQGridView I got a lot of troubles, I suggest You should give a try to UICollectionView. Cheers!

How can open viewcontroller immediately on click on button

I am developing an e-com app for iPhone in which i need to open a view immediately when the user clicks on a button for the upcoming view, the data loads large images from server , to load images I am using a background thread .
Thank You
Simple, here's how to create a UIViewController and present it from within an IBAction.
- (IBAction)goToNextView:(id)sender
{
//if you are using xibs use this line
UIViewController *controller = [[UIViewController alloc] initWithNibName:#"myXib" bundle:[NSBundle mainBundle]];
//if you are using storyboards use this line
UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:#"myViewControllersID"];
//to present the controller modally use this
[self presentViewController:controller animated:NO completion:nil];
//or if you are pushing to this controller using a navigation controller use this
[self.navigationController pushViewController:controller animated:NO];
}
Be sure to pass animated NO so that the view is displayed immediately.
You need to make a button and then add its action like
-(IBAction)ButtonAction:(id)sender{
CalController *calculateView=[[CalController alloc] initWithNibName:#"CalController" bundle:nil];
[self.navigationController presentModalViewController:calculateView animated:NO];
}
You can use modal view controller for this
- (IBAction)showController:(id)sender {
SampleViewController *sampleView = [[SampleViewController alloc] init];
[self presentModalViewController:sampleView animated:YES];
}
Here it is the tutorial http://timneill.net/2010/09/modal-view-controller-example-part-1/

viewWillAppear method is not calling iPhone SDK

navigated from one view to another will and when i pop my view back viewWillAppear method is not calling.
can you please let me know the reason.
When you load View the first time viewWillAppear method is called? try to use
[[self navigationController] popViewControllerAnimated:TRUE];
to return back
It's typical that these problems are caused by improper use of view controller containment. You need to look at your view controller hierarchy and research the following methods:
[UIViewController addChildViewController:];
[UIViewController removeFromParentViewController:];
[UIViewController transitionFromViewController:toViewController:duration:options:animations:completion:]
[UIViewController willMoveToParentViewController:]
[UIViewController didMoveToParentViewController:]
Read the Implementing a Container View Controller section of the UIViewController Class Reference.
If u are doing all well than ur application is crashed some where, use break point and check , even you can check and follow these steps......
step 1. for push in FirstViewController
SecondViewController *second = [[SecondViewController alloc]init]
[self.navigationController pushViewController:second animated:TRUE];
Step 2. for pop in SecondViewController
//check navigation controller exist in ur application stack
NSArray *arrView = [self.navigationController viewControllers];
NSLog(#"arrView %#",arrView);
for(int i = 0; i <[arrView count]-1, i++)
{
if([arrView objectAtIndex:i] isKindOfClass:[FirstViewController class])
{
[self.navigationController popViewControllerAnimated:TRUE];
}
}
I've also met this situation.
In iOS 5, it's ok.
But when I test in iOS 4.3.1, viewWillAppear is not calling.
So you need call viewWillAppear manually
You can try this
[[self.navigationController.viewControllers objectAtIndex:0] viewWillAppear:YES];
[self.navigationController popViewControllerAnimated:YES];

unable to switch from multiple views

I have a simple app with only location services and 3 (almost empty) different views, and from some reason I can't get from view 1 to view 2 - app crashes and I get an exception. View 1 is the original .xib file, the two others are just views that I added later. It's weird cause I can switch between all of them (1->3, 2->1, 2->3, etc..) just not from 1->2.
I use this code in #1 view controller m. file:
- (IBAction) switchToMaps : (id)sender //this is the one that doesnt work
{
MyMap *mapsView = [[MyMap alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:mapsView animated:YES];
}
- (IBAction) switchToThird : (id)sender
{
ThirdView *third = [[ThirdView alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:third animated:YES];
}
and as another example, here is the code from the 2nd view controller (MyMaps.m):
- (IBAction) switchBack : (id)sender
{
LastLocationViewController *firstView = [[LastLocationViewController alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:firstView animated:YES];
}
- (IBAction) switchFront : (id)sender
{
ThirdView *lastView = [[ThirdView alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:lastView animated:YES];
}
I know it's super vague, but any ideas what can cause this? I have no idea how to debug this...I even put breakpoints at the beginning of each IBAction method, and when it crashes, it doesnt even stop there....before I added this code, this app (which has only location) worked totally fine.
Any ideas?? Thanks!!
if your view does not load from any nib file then you should do like
MyMap *mapsView = [[MyMap alloc] init];
and
ThirdView *lastView = [[ThirdView alloc] init];
and in your back method
- (IBAction) switchBack : (id)sender
{
// LastLocationViewController *firstView = [[LastLocationViewController alloc] initWithNibName:nil bundle:nil]; // because you are allocating new memory to your last view
// [self presentModalViewController:firstView animated:YES];
[self dismissModalViewControllerAnimated:YES];
}
- (IBAction) switchFront : (id)sender
{
// ThirdView *lastView = [[ThirdView alloc] initWithNibName:nil bundle:nil];
// [self presentModalViewController:lastView animated:YES];
[self dismissModalViewControllerAnimated:YES];
}
My hunch is that you're throwing an exception because
MyMap *mapsView = [[MyMap alloc] initWithNibName:nil bundle:nil];
is failing to load a nib. Without seeing your console output it's impossible to say for sure. So a few things to try:
Comment out [self presentModalViewController:mapsView animated:YES];, see if it still crashes.
Explicitly name the nib you expect to load. The nib loader assumes the nib is named exactly the same as the view controller if you pass in nil. So if you don't have a match, you'll end up with an exception (Like this [[MyMap alloc] initWithNibName:#"NibNameWithoutExtension" bundle:nil];)
Set a breakpoint at [self present... and then hover your mouse over "mapsView" after execution pauses. If the popup thing shows you mapsView is nil, you know your trouble is trying to pass a nil object to -presentModalViewController:animated:. If your breakpoint never hits because you throw an exception first, well, there you go, the trouble is a line above.
edit:
One more thing. If your nib has a button that's wired to an action that no longer exists, that would definitely get you in trouble. Inspect each button and make sure no actions are labeled in yellow, indicating a mismatch between the button's target and the actions it's reporting to IB. This would definitely account for the breakpoint behavior you described.

App crashes on iPhone 4?

This code causes my app to crash on an iPhone 4 and on the simulator but works perfectly fine on a 3GS. Any ideas why this might be?
-(IBAction)startButtonClicked{
GameViewController *screen = [[GameViewController alloc] initWithNibName:nil bundle:nil];
screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:screen animated:YES];
[screen release];
}
Have you checked out what's happening in screen's viewWillAppear and viewWillLoad methods? It looks like some issue in your init code there. Where are you opening a URL?