Universal Master-Detail Storyboard help on segue - iphone

I am trying to make my first Universal app using iPhone and iPad storyboards.
I have a very simple app that show a list on the UITable and the detail of the item when clicked.
It works fine for iPhone, I created a segue to push the detail view ans its working fine with this code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self performSegueWithIdentifier:#"detail" sender:nil];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:#"detail"])
{
NSIndexPath *selectedIndex = [self.tableView indexPathForSelectedRow];
// Get reference to the destination view controller
self.detailViewController = [segue destinationViewController];
// Pass any objects to the view controller here, like...
self.detailViewController.detailDict = [myArray objectAtIndex:selectedIndex.row];
}
}
I dont know if that make any difference but I have set up my iPad to work only on landscape.
Anyway, how can I optimize this code to work on the iPad story board too?
I have already tried different segues for iPad but none of them worked. I get (gdb)

I ended up with this code. It's working for iOS 5 and 6
#pragma mark - Orientations
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
else
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
And to be sure I checked the buttons on the Target > Summary > Supported Interface Orientations

Related

I want to restrict some of the view controller to landscape in ios6

I'm trying to restrict one view controller which on top of UINavigationController. To do that i've created a UINavigationController subclass and implemented 2 methods
- (BOOL)shouldAutorotate {
return [[self.viewControllers lastObject] shouldAutorotate];}
- (NSUInteger)supportedInterfaceOrientations {
return [[self.viewControllers lastObject] supportedInterfaceOrientations];}
I want the first viewcontroller on top of UINavigationController(which is Root View Controller) should be in portrait mode and the next view controller which i'm pushing from the root view controller should be Landscape mode(ONLY).
So i'm overriding those two methods in both view controllers.
In the root view controller
- (BOOL)shouldAutorotate {
return NO;}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;}
In the next view controller
- (BOOL)shouldAutorotate {
return YES;}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;}
Its working fine but not completely. For the first time when I push the view controller its showing in portrait mode(Not restricting to landscape as I expected) and once I rotate the device/simulator and its working fine and restricting to landscape only.
Can anyone help in this?
Try this out.
Call this one in the viewWillAppear will explicitly tell the device to jump to the portrait orientation.
[[UIDevice currentDevice] performSelector:NSSelectorFromString(#"setOrientation:") withObject:(id)UIInterfaceOrientationPortrait];
I don't think this is the right solution. But if you got no other options, you can use this.
Happy Coding :)
U present new controller :
SecondViewController *objSecondViewController = [[SecondViewController alloc]initWithNibName:#"SecondViewController" bundle:nil];
[self.navigationController presentViewController:objSecondViewController animated:NO completion:^{}];
In new controller :
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
This worked for me. Just try using this :
1) YourApp-Info.plist
Add one more array for Supported interface orientations
Add your required orientation to this dictionary
Refer below screenshot :
2) Project Target
Select the required orientation from Supported Interface Orientations
Refer below screenshot :
UIViewController have the following function. You can implement this in your view controller where you want to restict portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
if(interfaceOrientation == UIInterfaceOrientationPortrait)
return YES;
else
return NO;
}

editingStyleForRowAtIndexPath -- fires in iOS 5, does not fire in iOS 6

I have simple master and detail view controllers connected with two segues, one for "show detail" and one for "add new".
"Show detail" segues to the detail view controller with setEditing:NO.
Tap "+" (add icon) segues to the detail view controller with setEditing:YES
iOS 5.1: "+" works as I expect, the detail page is in edit mode and editingStyleForRowAtIndexPath fires to show the insert and delete indicators.
iOS 6.0: the "+" makes the transition to the detail page but editingStyleForRowAtIndexPath never fires. Other code that is in setEditing:YES gets executed. didSelectRowAtIndexPath does fire (delegate = self).
Once on the detail page edit mode works as expected in both cases.
Any ideas?
// Master.m
if([[segue identifier] isEqualToString:#"NewRecipe"]) {
DetailViewController *detailViewController = [segue destinationViewController];
// stuff
detailViewController.recipe = r;
detailViewController.delegate = self;
detailViewController.editing = YES;
}
// Detail.m
-(void)setEditing:(BOOL)flag animated:(BOOL)animated {
if (flag) {
[self.tableView setEditing:flag animated:YES];
[self.tableView beginUpdates];
// the row does get added
[self.tableView insertRowsAtIndexPaths:#[pathToAdd] withRowAnimation:UITableViewRowAnimationAutomatic];
// datasource gets updated here
[self.tableView endUpdates];
....
}
}
I figured it out. I don't know why this is the fix, I hope this does not replace bad code with worse code.
Master.m
// iOS 5 -- this is OK
detailViewController.editing = YES;
For iOS 6 I needed the detailViewController to make a call to a delegate method to determine whether to setEditing:YES.
Master.m
-(BOOL)isNewRecipe {
return (_isNewRecipe == 1);
}
Detail.m
if ([self.delegate isNewRecipe]) {
[self setEditing:YES];
}

IOS 6 force device orientation to landscape

I gave an app with say 10 view controllers. I use navigation controller to load/unload them.
All but one are in portrait mode. Suppose the 7th VC is in landscape. I need it to be presented in landscape when it gets loaded.
Please suggest a way to force the orientation go from portrait to landscape in IOS 6 (and it will be good to work in IOS 5 as well).
Here is how I was doing it BEFORE IOS 6:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
UIViewController *c = [[[UIViewController alloc]init] autorelease];
[self presentModalViewController:c animated:NO];
[self dismissModalViewControllerAnimated:NO];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
Presenting and dismissing a modal VC was forcing the app to review its orientation, so shouldAutorotateToInterfaceOrientation was getting called.
What I have have tried in IOS 6:
- (BOOL)shouldAutorotate{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
return UIInterfaceOrientationLandscapeLeft;
}
On load, the controller keeps staying in portrait. After rotating the device, the orientation changes just ok. But I need to make the controller to rotate automatically to landscape on load, thus the user will have to rotate the device to see the data correctly.
Another problem: after rotating the device back to portrait, the orientation goes to portrait, although I have specified in supportedInterfaceOrientations only UIInterfaceOrientationMaskLandscape. Why it happens?
Also, NONE of above 3 methods are getting called.
Some (useful) data:
In my plist file I have specified 3 orientations - all but upside down.
The project was started in Xcode 4.3 IOS 5. All classes including xibs were created before Xcode 4.5 IOS 6, now I use the last version.
In plist file the status bar is set to visible.
In xib file (the one I want to be in landscape) the status bar is "None", the orientation is set to landscape.
Any help is appreciated. Thanks.
Ok, folks, I will post my solution.
What I have:
A view based application, with several view controllers. (It was navigation based, but I had to make it view based, due to orientation issues).
All view controllers are portrait, except one - landscapeLeft.
Tasks:
One of my view controllers must automatically rotate to landscape, no matter how the user holds the device. All other controllers must be portrait, and after leaving the landscape controller, the app must force rotate to portrait, no matter, again, how the user holds the device.
This must work as on IOS 6.x as on IOS 5.x
Go!
(Update Removed the macros suggested by #Ivan Vučica)
In all your PORTRAIT view controllers override autorotation methods like this:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
return (toInterfaceOrientation == UIInterfaceOrientationPortrait);
}
-(BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
You can see the 2 approaches: one for IOS 5 and another For IOS 6.
The same for your LANDSCAPE view controller, with some additions and changes:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
[image_signature setImage:[self resizeImage:image_signature.image]];
return (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
-(BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
[image_signature setImage:[self resizeImage:image_signature.image]];
return UIInterfaceOrientationMaskLandscapeLeft;
}
ATTENTION: to force autorotation in IOS 5 you should add this:
- (void)viewDidLoad{
[super viewDidLoad];
if ([[[UIDevice currentDevice] systemVersion] floatValue] < 6.0)
[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationLandscapeLeft animated:NO];
}
Analogically, after you leave the LANDSCAPE controller, whatever controller you load, you should force again autorotation for IOS 5, but now you will use UIDeviceOrientationPortrait, as you go to a PORTRAIT controller:
- (void)viewDidLoad{
[super viewDidLoad];
if ([[[UIDevice currentDevice] systemVersion] floatValue] < 6.0)
[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationPortrait animated:NO];
}
Now the last thing (and it's a bit weird) - you have to change the way you switch from a controller to another, depending on the IOS:
Make an NSObject class "Schalter" ("Switch" from German).
In Schalter.h say:
#import <Foundation/Foundation.h>
#interface Schalter : NSObject
+ (void)loadController:(UIViewController*)VControllerToLoad andRelease:(UIViewController*)VControllerToRelease;
#end
In Schalter.m say:
#import "Schalter.h"
#import "AppDelegate.h"
#implementation Schalter
+ (void)loadController:(UIViewController*)VControllerToLoad andRelease:(UIViewController*)VControllerToRelease{
//adjust the frame of the new controller
CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
CGRect windowFrame = [[UIScreen mainScreen] bounds];
CGRect firstViewFrame = CGRectMake(statusBarFrame.origin.x, statusBarFrame.size.height, windowFrame.size.width, windowFrame.size.height - statusBarFrame.size.height);
VControllerToLoad.view.frame = firstViewFrame;
//check version and go
if (IOS_OLDER_THAN_6)
[((AppDelegate*)[UIApplication sharedApplication].delegate).window addSubview:VControllerToLoad.view];
else
[((AppDelegate*)[UIApplication sharedApplication].delegate).window setRootViewController:VControllerToLoad];
//kill the previous view controller
[VControllerToRelease.view removeFromSuperview];
}
#end
NOW, this is the way you use Schalter ( suppose you go from Warehouse controller to Products controller ) :
#import "Warehouse.h"
#import "Products.h"
#implementation Warehouse
Products *instance_to_products;
- (void)goToProducts{
instance_to_products = [[Products alloc] init];
[Schalter loadController:instance_to_products andRelease:self];
}
bla-bla-bla your methods
#end
Of course you must release instance_to_products object:
- (void)dealloc{
[instance_to_products release];
[super dealloc];
}
Well, this is it. Don't hesitate to downvote, I don't care. This is for the ones who are looking for solutions, not for reputation.
Cheers!
Sava Mazare.
This should work, it's similar to the pre-iOS 6 version, but with a UINavigationController:
UIViewController *portraitViewController = [[UIViewController alloc] init];
UINavigationController* nc = [[UINavigationController alloc] initWithRootViewController:portraitViewController];
[self.navigationController presentModalViewController:nc animated:NO];
[self.navigationController dismissModalViewControllerAnimated:NO];
I'm calling this before I'm pushing the next UIViewController. It will force the next pushed UIViewController to be displayed in Portrait mode even if the current UIViewController is in Landscape (should work for Portrait to Landscape too). Works on iOS 4+5+6 for me.
I think that best solution is to stick to official apple documentation. So according to that I use following methods and everything is working very well on iOS 5 and 6.
In my VC I override following methods:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
Methods for iOS 6, first method returns supported orientation mask (as their name indicate)
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortrait;
}
second one thats tells your VC which is preferred interface orientation when VC is going to be displayed.
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
Just change Portrait for orientation that you want ;)
This solution is working smooth, I don't like the idea of creating macros and other stuff, that goes around this simple solution.
Hope this help...
I had the same problem, 27 views in my application from which 26 in portrait and only one in all orientations ( an image viewer :) ).
Adding the macro on every class and replace the navigation wasn't a solution I was comfortable with...
So, i wanted to keep the UINavigationController mechanics in my app and not replace this with other code.
What to do:
#1 In the application delegate in method didFinishLaunchingWithOptions
if ([[UIDevice currentDevice].systemVersion floatValue] < 6.0)
{
// how the view was configured before IOS6
[self.window addSubview: navigationController.view];
[self.window makeKeyAndVisible];
}
else
{
// this is the code that will start the interface to rotate once again
[self.window setRootViewController: self.navigationController];
}
#2
Because the navigationController will just responde with YES for autorotation we need to add some limitations:
Extend the UINavicationController -> YourNavigationController and link it in the Interface Builder.
#3 Override the "anoying new methods" from navigation controller.
Since this class is custom only for this application it can take responsibility
for it's controllers and respond in their place.
-(BOOL)shouldAutorotate {
if ([self.viewControllers firstObject] == YourObject)
{
return YES;
}
return NO;
}
- (NSUInteger)supportedInterfaceOrientations {
if ([self.viewControllers firstObject] == YourObject)
{
return UIINterfaceOrientationMaskLandscape;
}
return UIInterfaceOrientationMaskPortrait;
}
I hope this will help you,
From the iOS 6 Release Notes:
Now, iOS containers (such as UINavigationController) do not consult their children to determine whether they should autorotate.
Does your rootViewController pass the shouldAutoRotate message down the ViewController hierarchy to your VC?
I used the same method as OP pre-ios6 (present and dismiss a modal VC) to show a single view controller in landscape mode (all others in portrait). It broke in ios6 with the landscape VC showing in portrait.
To fix it, I just added the preferredInterfaceOrientationForPresentation method in the landscape VC. Seems to work fine for os 5 and os 6 now.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
- (BOOL)shouldAutorotate
{
return NO;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
Hey guys after tryng a lot of different possible solutions with no success i came out with the following solution hope it helps!.
I prepared a recipe :).
Problem:
you need change orientation of viewcontrollers using navigationcontroller in ios 6.
Solution:
step 1. one initial UIviewcontroler to trigger modal segues to landscape and
portrait UInavigationControllers as picture shows....
more deeply in UIViewController1 we need 2 segues actions according to global variable at Appdelegate....
-(void)viewDidAppear:(BOOL)animated{
if([globalDelegate changeOrientation]==0){
[self performSegueWithIdentifier:#"p" sender:self];
}
else{
[self performSegueWithIdentifier:#"l" sender:self];
}
}
also we need a way back to portrait &| landscape....
- (IBAction)dimis:(id)sender {
[globalDelegate setChangeOrientation:0];
[self dismissViewControllerAnimated:NO completion:nil];
}
step 2. the first Pushed UiViewControllers at each NavigationController goes
with...
-(NSUInteger)supportedInterfaceOrientations{
return [self.navigationController supportedInterfaceOrientations];
}
-(BOOL)shouldAutorotate{
return YES;
}
step 3. We overwrite supportedInterfaceOrientations method at subclass of UInavigationController....
in your customNavigationController we have .....
-(NSUInteger)supportedInterfaceOrientations{
if([self.visibleViewController isKindOfClass:[ViewController2 class]]){
return UIInterfaceOrientationMaskPortrait;
}
else{
return UIInterfaceOrientationMaskLandscape;
}
}
step 4. At storyboard or by code, set wantsFullScreenLayout flag to yes, to both portrait and landscape uinavigationcontrollers.
Try segueing to a UINavigationController which uses a category or is subclassed to specify the desired orientation, then segue to the desired VC. Read more here.
As an alternative you can do the same using blocks:
UIViewController *viewController = [[UIViewController alloc] init];
viewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:viewController animated:NO completion:^{
[self dismissViewControllerAnimated:NO completion:nil];
}];
Also, call it before pushing the new view.
Go to you Info.plist file and make the change
I had the same problem. If you want to force a particular view controller to appear in landscape, do it right before you push it into the navigation stack.
UIInterfaceOrientation currentOrientation = [[UIApplication sharedApplication] statusBarOrientation];
if (currentOrientation == UIInterfaceOrientationPortrait ||
currentOrientation == UIInterfaceOrientationPortraitUpsideDown)
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeLeft];
UIViewController *vc = [[UIViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
[vc release];
I solved it by subclassing UINavigationController and overriding the supportedInterfaceOrientations of the navigation Controller as follow:
- (NSUInteger)supportedInterfaceOrientations
{
return [[self topViewController] supportedInterfaceOrientations];
}
All the controllers implemented supportedInterfaceOrientations with their desired orientations.
I have used the following solution. In the one view controller that has a different orientation than all the others, I added an orientation check in the prepareForSegue method. If the destination view controller needs a different interface orientation than the current one displayed, then a message is sent that forces the interface to rotate during the seque.
#import <objc/message.h>
...
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if(UIDeviceOrientationIsLandscape(self.interfaceOrientation))
{
UIInterfaceOrientation destinationOrientation;
if ([[segue destinationViewController] isKindOfClass:[UINavigationController class]])
{
UINavigationController *navController = (UINavigationController *)[segue destinationViewController];
destinationOrientation = [navController.topViewController preferredInterfaceOrientationForPresentation];
} else
{
destinationOrientation = [[segue destinationViewController] preferredInterfaceOrientationForPresentation];
}
if ( destinationOrientation == UIInterfaceOrientationPortrait )
{
if ([[UIDevice currentDevice] respondsToSelector:#selector(setOrientation:)])
{
objc_msgSend([UIDevice currentDevice], #selector(setOrientation:), UIInterfaceOrientationPortrait );
}
}
}
}

Using Facebook "iOS native deep linking" and openURL with iOS 5 storyboard/segue based app?

I have an Facebook enabled, iOS 5 app that uses a storyboard and segue based navigation and am confused on how to implement "iOS native deep linking." The example code at Improving App Distribution on iOS just displays a UIAlertView but I am trying to initiate two consecutive seque operations.
For purposes of this question, I've simplified the application to three view controllers: MYCategoryTableViewController, MYItemsTableViewController and MYItemViewController. In the normal flow, the application opens to MYCategoryTableViewController, which displays a table of categories. When a category is selected by the user, there is a segue to MYItemsTableViewController which displays a table of items for that selected category. Lastly, when an item is selected, there is a segue to MYItemViewController which displays an item detail view.
The prepareForSegue from MYCategoryTableViewController sets a property on the destination view controller that represents that category:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:#"ITEMS_SEGUE"]) {
MYItemsTableViewController *vc = [segue destinationViewController];
MYCategory *mycategory = [self.fetchedResultsController objectAtIndexPath:[self.tableView indexPathForSelectedRow]];
vc.mycategory = mycategory;
}
}
The prepareForSegue from MYItemsTableViewController sets a property on the destination view controller that represents that category:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:#"ITEM_SEGUE"]) {
MYItemViewController *vc = [segue destinationViewController];
MYItem *myitem = [self.fetchedResultsController objectAtIndexPath:[self.tableView indexPathForSelectedRow]];
vc.myitem = myitem;
}
}
Question: I know that I need to implement something in application:openURL, but not sure what to do next. Assume the incoming URL gives identifiers to lookup the MYCategory and MYItem objects. I found performSegueWithIdentifier but not sure how that interacts with prepareForSegue and how I set my model objects on the destination view controllers.
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
// get "target_url" from incoming url
// and parse out MYCategory and MYItem identifiers
// something like this???
[self.window makeKeyAndVisible];
[self.window.rootViewController performSegueWithIdentifier:#"ITEM_SEGUE" sender:self];
return [facebook handleOpenURL:url];
}
Update: Selecting programmatically a cell on a tableview doesn't perform associated segue has given me an idea. Maybe I just save off the url from application:openURL: and let MYCategoryTableViewController load naturally. Then during viewWillAppear, call tableView selectRowAtIndexPath and then performSegueWithIdentifier to transition to MYItemsTableViewController. Repeat the same pattern in MYItemsTableViewController, but clear out the url before the performSegueWithIdentifier call.
Here is what I got working. In MYAppDelegate, I captured a string represented the id of the deep link.
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
NSString *deepLinkId;
// more code that parses url
// only deep link if MYCategoryTableViewController is active controller
UIViewController *rootContoller = self.window.rootViewController;
if ([rootContoller isKindOfClass:[UINavigationController class]]) {
UINavigationController *navController = (UINavigationController *)rootContoller;
if ([navController.topViewController isKindOfClass:[MYCategoryTableViewController class]]) {
self.deepLinkId = deepLinkId;
}
}
}
Then, when MYCategoryTableViewController loads, call selectRowAtIndexPath and then performSegueWithIdentifier.
- (void)processDeepLink {
if (_appDelegate.deepLinkId) {
MYItem *myitem = [MYItem lookupById:_appDelegate.deepLinkId inManagedObjectContext:_appDelegate.dataDocument.managedObjectContext];
if (myitem) {
NSIndexPath *indexPath = [self.fetchedResultsController indexPathForObject:myitem.mycategory];
[self.tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionMiddle];
[self performSegueWithIdentifier:#"ITEMS_SEGUE" sender:self];
}
}
}
And in when MYItemViewController loads, a similar flow.
if (_appDelegate.deepLinkId) {
MYItem *plate = [MYItem lookupById:_appDelegate.deepLinkId inManagedObjectContext:_appDelegate.dataDocument.managedObjectContext];
NSIndexPath *indexPath = [self.fetchedResultsController indexPathForObject:plate];
[self.tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionMiddle];
_appDelegate.deepLinkId = nil;
[self performSegueWithIdentifier:#"ITEM_SEGUE" sender:self];
}
I also had to observe UIApplicationDidBecomeActiveNotification for the use case when the application was already open.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(processDeepLink)
name:UIApplicationDidBecomeActiveNotification
object:nil];

If-statement in prepareForeSegue in iOS 5

I have a problem with the Storyboard in xCode 4.2. Is it posible to check, if a boolean is true to load the next view or if it is false to do not load the new view an stay in the actual view.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:#"toCategory"] && ([[codeField text] isEqualToString:#"1234"]))
{
QuestInfoController *qicontroller = [segue destinationViewController];
}
else
{
[super prepareForSegue:segue sender:self];
return;
}
}
Yes, but you don't do it quite like this. You'd use a custom method or check for your boolean value - then you'd use performSegueWithIdentifier: to force the transition based on the outcome.
I wrote another post about it here. It demonstrates how to wire a few buttons on a page to push the next view. Note that in the buttonPressed: method would be where you do your check.