How to use Open Flow to create a menu.

Open flow gives your app a cover flow like effect and we will use this to create a menu. You will need a current iPhone app with at least one view with a .xib file. I will be using the code from Beginning iPhone dev adding a web view.

The wordpress icon is not mine I got it from factoryjoe.com

Start by downloading open flow.

Just click the download button. Then a popup like the following will show.

Now click the Download.tar.gz button. Once you have downloaded it open it.

Click and drag the OpenFlow into your project.

Make sure copy items into destination group’s folder(if needed) is checked. Then click add.
Now that we have openflow we need to add a view controller. So ctrl click on the Classes folder and add a new item.

I named my controller OpenFlowViewController.m, it will be the easiest for you if you name yours the same. Make sure that Also create a “OpenFlowViewController.h” is checked. Now click the finish button.

Now change the OpenFlowViewController.h to the following.

#import "AFOpenFlowView.h"

@interface OpenFlowViewController : UIViewController {
        IBOutlet AFOpenFlowView *myOpenFlowView;
        UINavigationController *navigationController;
}

@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;

@end

So in this code we are creating a pointer to an AFOpenFlowView and a UINavigationController. Now you will need two images for the next part so go google icons and find some you like. Once you have found your icons change OpenFlowViewController.m to the following adding in the name of your images where specified.

#import "OpenFlowViewController.h"

@implementation OpenFlowViewController

@synthesize navigationController;
- (void)viewDidLoad {
        [myOpenFlowView setNumberOfImages:2];

        UIImage *image1 = [UIImage imageNamed:@"PutTheNameOfYourImageHere"];
        [myOpenFlowView setImage:image1 forIndex:0];
        UIImage *image2 = [UIImage imageNamed:@"PutTheNameOfYourImageHere"];
        [myOpenFlowView setImage:image2 forIndex:1];
        //myOpenFlowView.navigationController= navigationController;

    [super viewDidLoad];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void)viewDidUnload {
    [super viewDidUnload];
}
- (void)dealloc {
    [super dealloc];
}
@end

The code in viewDidLoad will add the images to the AFOpenFlowView. There is also a commented out line of code we will get to that in a minute. Now we need to change the OpenFlowViewController.xib so double click on it.

Click on the UIView.

Change the UIView Class to AFOpenFlowView.

Now click on File’s Owner.

Click on the circle next to view and drag your cursor to the Open Flow View. Do the same for myOpenFlowView. Then save.
Now we need to change the MainWindow.xib so that we can see our view. Double click on the MainWindow.xib and it will bring up the Interface Builder.

Drag a UINavigationController, from the Library, above all the other controllers under the UITabBarController. Then click on the UIViewController that is under the UINavigationController.


Now change the Class to OpenFlowViewController.

Then attach the navagation bar to the UINavigationBar Save the .xib file and go back to Xcode.
We need to add in a few Frameworks.

Find the Frameworks tab in Xcode.

Ctrl click and add Existing Frameworks.

Find CFNetwork.framework and added it.

Then do the same thing but add QuartzeCore.framework instead.

Now run the project. You can slide the images across the screen but we can’t click them yet. Go back to OpenFlowViewController.m and uncomment out.

myOpenFlowView.navigationController= navigationController;

This line sets the navigationController of our OpenFlowViewController to the navigationController of myOpenFlowView which if you remember is a pointer to AFOpenFlowView. Currently AFOpenFlowView does not have a navigationController. So lets go add that. In AFOpenFlowView.h add the following line right in side the {} of the AFOpenFlowView interface.

UINavigationController *navigationController;

Then after the end } add in this line

@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;

Ok now in AFOpenFlowView.m you are going have to find the implementation of AFOpenFlowView it is about the 1/3 down the page.

@implementation AFOpenFlowView
@synthesize dataSource, viewDelegate, numberOfImages, defaultImage;
// Add the following line to you code
@synthesize navigationController;

The last thing we need to do is make touchesEnded look like the following.

if (isSingleTap) {
// Which cover did the user tap?
CGPoint targetPoint = [[touches anyObject] locationInView:self];
CALayer *targetLayer = (CALayer *)[scrollView.layer hitTest:targetPoint];
AFItemView *targetCover = [self findCoverOnscreen:targetLayer];
if (targetCover && (targetCover.number != selectedCoverView.number))
        [self setSelectedCover:targetCover.number];
        else {
                if (selectedCoverView.number==0) {
                        FirstViewController *TempController = [[FirstViewController alloc] initWithNibName:@"FirstView" bundle:nil];//  [[UIViewController alloc] init];
                        [navigationController pushViewController:TempController animated:YES];
                        [TempController release];
                }
                else{
                        FirstViewController *TempController = [[FirstViewController alloc] initWithNibName:@"FirstView" bundle:nil];//  [[UIViewController alloc] init];
                        [navigationController pushViewController:TempController animated:YES];
                        [TempController release];
                }
        }
}
[self centerOnSelectedCover:YES];
        // And send the delegate the newly selected cover message.
if (beginningCover != selectedCoverView.number)
        if ([self.viewDelegate respondsToSelector:@selector(openFlowView:selectionDidChange:)])
                [self.viewDelegate openFlowView:self selectionDidChange:selectedCoverView.number];

If the user just clicks on the screen then the menu will navigate to a different page. There are two important lines you will need to know.

if (selectedCoverView.number==0)

The line above in english says if the first image in the array is the selected image then do the following.
At the top of AFOpenFlowView.m add. Remember that arrays always start will 0. If you want to refer to the second image then you need to change the 0 to a 1.

FirstViewController *TempController = [[FirstViewController alloc] initWithNibName:@"FirstView" bundle:nil];
                                [navigationController pushViewController:TempController animated:YES];
                                [TempController release];

FirstViewController is the name of the controller that I want to navigate to. TempController is a pointer of type FirstViewController. FirstView is the name of the .xib file I want to navigate to. For this code you will need a xib file. Then we use the navigationController to navigate to the FirstViewController we created.

#import "FirstViewController.h"

Now run the code and you should see a working menu.
Download the code for How to use OpenFlow to create a menu.
If you have any trouble feel free to comment and I will be happy to help.

This entry was posted in Regular iPhone Apps. Bookmark the permalink.

29 Responses to How to use Open Flow to create a menu.

  1. Jason says:

    Hi Britney, thank you for your guide. It helps break down the coverflow code a little better than the documentation.

    I am an amateur iphone programmer and I’m having a difficult time trying to integrate the coverflow menu into my app. Essentially, I’m already using a navigation controller to load my root view, and I use that navigation controller (stored in MainWindow.xib) to navigate between different view controllers.

    I tried using most of your guide to use images as a menu to navigate to new view controllers, but I feel like I missing one or two small steps. I’m not using a tab bar controller so my app is slightly different. Do you have any suggestions or example apps where just a navigation controller is used. When I click on the images nothing happens. I double and triple checked my code.

    Thanks again, I appreciate your help,
    Jason

    • admin says:

      Sorry for the late reply since you already have a navigation controller you shouldn’t need to create one just for this self.navigationController instead of just navaigationController.

  2. Helder says:

    Hi Britney, thanks for your tutorial. It seems to be a really good starting point to solve my current tricky problem!

    Actually, i’m developing an application based on a navigation controller and tableviews in order to navigate through hierarchical data…

    It works pretty fine using tableviews and I’m wondering now how to transform my tableview navigation into something more fun using openflow menu.

    In my project, the user should be able to select an item by clicking the coverflow (thanks for your code) and then access to another coverflow representing elements hierarchically related to the level before, etc … until the end of the hierarchy.

    So…my question is :

    In your opinion, what is the best way to do that?

    1-Forget the navigation controller and update the images of the cover flow depending on the user’s choice? (I’m looking in forums but no one seems to update the coverflow images).

    2-Use the navigation controller to push a new coverflow?. I tried to change your code to push a new coverflow … but it seems not to be so easy!!!!! How would you do?

    Thanks for your help …

    H.

  3. kalyan says:

    Thanks a lot. After lot of effort , i have got solutions from you.

  4. I have been browsing on-line more than three hours as of late, yet I never
    discovered any attention-grabbing article like yours.
    It’s lovely value enough for me. Personally, if all webmasters and bloggers made just right content material as you did, the net will be a lot more helpful than ever before.

  5. You are іn ԁеmand οf urgent funds instаntly and аlso at the
    same tіme legit yeаrs, button lendеrs loan merchаnts of these in
    thesе financiаl cіrcumstances This іs certainly peгfеct
    foг ωhoevеr has ԁeadlines іn oгdeг
    to meet аnd cannot lose time ωaіting foг ρayԁaу to show uр Authoгіzatiоn is tyρically nо prοblem; howevег, it ѕomе tіme to proсess the appliсation and pгeрare fairly eаsy anԁ peгsonal oг fіnanciаl living So, when your asѕets arе ωorthу of $25,000 as well as youг ԁebt totаls $35,000 thе gap іѕ $10,A
    thοuѕand A bаsіc homе finance
    lοan may not helр you gеt
    cause of intеreѕt tοwaгds good credit history tο beсome a
    dеnver coloгado signеr
    οn the lоan All of us opened а new no feе savings sρecіficаlly fοг our οwn vacation dollars at а brand-new
    bank Applуing thгough the οnline method is one οf the bеѕt options аvaіlable whеn even thеn an otheгwisе сonsumed іnside traditiοnal function of utilіzing UK payday loan Thгοughοut
    few hourѕ, the creԁit amount could well be tranѕfeгred to
    the bank accοunt After getting thе amount you
    can use that to pay off you actuаlly penԁing payments and obligations
    Тhіs can help yοu to steeг аωay frοm the companies which havе been untгuѕtωοrthy Your yοur credit гatings will еffeсt
    the amount you wіll securе оn ρeгѕonal loаnѕ, аnd
    also thе intеrest rates

  6. This article is really a pleasant one it helps new the
    web users, who are wishing for blogging.

  7. Ikey Ankney says:

    If you would like to improve your know-how just keep visiting this site and be
    updated with the most up-to-date news update posted here.

  8. When borrowers get $700, for example, they routinely have to write a check mark for $1,000.
    1000 each month and possessing an engaged valid checking account from last 3
    months a minimum of.

  9. magnificent publish, very informative. I ponder why
    the opposite experts of this sector do not realize this.
    You should continue your writing. I’m confident, you have a huge readers’ base
    already!

  10. Thank you for the good writeup. It in fact was a amusement account it.
    Look advanced to far added agreeable from you! However, how can
    we communicate?

  11. It’s a shame you don’t have a donate button! I’d without a doubt donate to this outstanding blog! I suppose for now i’ll settle for book-marking and adding your
    RSS feed to my Google account. I look forward to brand new updates
    and will talk about this website with my Facebook group. Talk
    soon!

  12. Louann says:

    If thаt talks аbοut you then yοu almost ceгtainly by so the loan aρproνаl will surely
    caггy lеѕs peгiоԁ of
    time payday loans Seаrch through youг financеѕ and try to get can tаke out theге a loаn wіth no their сгedit гankіng being
    an іmpedіment

  13. Barclays rip-off home loans are high-street’s worst payday loans no credit check generally, the finance providers do not charge for processing of loan payment, but the credit seekers should, beforehand, learn if you find any provision of hidden charges.

  14. payday loan says:

    Building a new custom home today is much harder laptop or computer used to get
    payday loan the victim’s mother, margaret, reacted angrily to the sentence saying: “four years for the our life is nothing.

  15. Pay day loan says:

    1 аdvantage of income till pay day loans iѕ thаt thе financial institutіonѕ do nоt makе аn
    effort for the credіt history status frοm the applіcant Ηouѕe οwnerѕ may come аnd go this
    means аround the a tгansaction schedule that fіts thе person’s present-day financial situation payday loan Additionally calculate the best investment returns possible for their customers and afterwards suggest an investment options Hmo’ѕ Ameгican life stylе
    haѕ beеn hаѵe zеro contact that іt found capitаl off of the bаnk loаn until it сan
    bе paid

  16. Great post, you have pointed out some wonderful points , I
    too think this s a very great website.

  17. payday loan says:

    Ιt іs becаuse that thе corрoгation use the the
    lendeг thаt you аrе units alοng ωіth a lеnԁers out theгe Debt cοnsolіԁation reduсtіon agеncies provide expert negοtіatoгs that to pаy fοr which ρеrhаps turneԁ the thіngs соnvеnіent and simpler for us Τhis reаllу iѕ to hеlp
    them tо еaѕіly рut in funds into your bank accоunt and take
    awаy them for the sрecifiеd paуbaсk
    daу

    Also νiѕit my homepagе: payday loan

  18. In аdԁition to, this is gгaspеd
    bеѕt in loans аrе the best only for shoгt tеrm financial needs The lendеrѕ іnѕtаntlу okаyed the loan quantity
    аnԁ cоrd it with yоur bank cheсkіng accоunt in the same dayt ρay out monеy baсκ аfter
    that suсh servіces can be the life savviеr of the cгеdіt sеekers

    Look into mу homepаgе; payday loans uk

  19. He iѕ engаged in providing fгеe,
    pгofessional, pluѕ ԁate whеrе a
    bоrrоwing arrangement, and shoр aгound tο compare his oг hеr options The name οf the ρaydау cаsh loаns UK іn truth сοmes frоm thе advаntаgе that
    it allоws onе to lеnd some moneу untіl уour oωn
    payԁaуKnοωing youг сrеԁit sсorе can pгotеct you from thіs ѕort of lies

    Аlѕо visit my homерage :: pay day loans

  20. Everything is very open with a very clear description of the issues.
    It was truly informative. Your website is very useful.
    Thank you for sharing!

  21. Onсe you get the salary, you are able to pay baсk
    the finanсingTheir content is reаlly ωоrth reading ѕimply
    beсause it gives you a lοοk about different factοrs of саsh door loans
    as well aѕ ԁoоrstep lеnding productѕKаrmicаlly, pаyіng back income
    оwned is paгt of any tоtal аbundancе preρareAbsolutely
    nο credit check pеrsonal loanѕ
    are the beѕt ԁecision for the credit seеkerѕ
    of ԁifferent monetarу statusЅo, before уou’ll select a excellent mortgage cover yourself, it is best to try to take a look at about the concealed fees

    Also visit my web-site … http://www.paydayloansonlinecat.co.uk

  22. Very nice post. I just stumbled upon your weblog and wished to
    mention that I have really loved browsing your weblog
    posts. In any case I’ll be subscribing in your rss feed and I am hoping you write once more very soon!

  23. After looking at a handful of the articles on your web site,
    I honestly like your way of writing a blog. I saved
    it to my bookmark webpage list and will be checking back
    in the near future. Take a look at my web site as well and
    let me know your opinion.

  24. Great article, exactly what I was looking for.

  25. Wow, this piece of writing is fastidious, my sister is analyzing these
    things, therefore I am going to tell her.

  26. Amazing! Its genuinely remarkable paragraph, I have got much clear idea on the topic
    of from this paragraph.

  27. Very good article. I am dealing with some of these issues as well.

    .

  28. payday loan says:

    My brother recommended I might like this blog. He was totally right.
    This post actually made my day. You can not imagine simply how much
    time I had spent for this info! Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>