Create a view containing clickable icons (?)

Discussion in 'iOS Programming' started by vcanic, Feb 23, 2010.

  1. vcanic macrumors newbie

    Joined:
    Feb 4, 2010
    #1
    Hello,

    For an app I am currently working on, I am trying to create a view that has a bunch of icons on it. Placed in some sort of a grid.

    Something similar to the Facebook iPhone app for example.
    Facebook iPhone screenshot

    What is the best view to use for drawing icons (images) on it that are clickable?

    I also found these libraries:
    http://www.arijasoft.com/products/iphone-gridview

    But I wonder if Apple allows views like that to be created (should you want to submit your app to the app store). Anyone who can answer this?

    Some help and advice is much appreciated. Thanks.
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    I don't know for certain but I don't see why not.
     
  3. HarryWorksInc macrumors regular

    Joined:
    Feb 21, 2010
    #3
    Probably

    Well if you found an example of this in your Facebook app then certainly you can do this too.

    I would just create a grid of CGPoints for the rows and weather with interface builder or if your building the interface programmatically, create buttons with the background images set to your icons. Then call each icon to lock into the grid.
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    Not necessarily, though. In this case, the grid view doesn't seem to violate any part of the SDK Agreement or the HIG, but just because "some other app is doing it" usually falls upon deaf ears with the App Review team. You cannot use the approval of another app as the basis for why your app should also be approved.
     
  5. HarryWorksInc macrumors regular

    Joined:
    Feb 21, 2010
    #5
    True

    Yea, i guess your right. The Appstore review team don;t seem to hold steady to ideas. Once a friend of mine had me make this really stupid app for him, a guy that walks around with ice cream on his head... i know. It got rejected for being to stupid.

    But on the other hand I have also found this in 2 other apps. I can defiantly see your point for 1 app but 3 apps out of just the ones i've seen kinda weighs on the side of possibility.

    Also never just give up try submitting it and see what happens
     
  6. vcanic thread starter macrumors newbie

    Joined:
    Feb 4, 2010
    #6
    Ahh i c, thanks for the explanation. Is it possible to attach objects to a UIButton? For example; if I want each button in the grid to be a representation of a person (let's say Person.h/Person.m object).

    So if the user clicks on a button than he/she is shown a view containing all the information of that person.
     
  7. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #7
    That's not really the approach that comes from using Model-View-Controller design pattern. Instead what you would probably have is some kind of model object to store your grid of Person objects (could be as simple as an NSArray) and the data from that store drives your UI. So, you might loop through the array to create the buttons (perhaps even using an image and a title from the Person object) as well as setting the tag to the index. Then, in the method that is triggered by the button push, you could retrieve the Person object based on the tag, and then present a new view controller based on that Person object.

    You can read much more about MVC in this Apple document as well all over the internet.
     
  8. vcanic thread starter macrumors newbie

    Joined:
    Feb 4, 2010
    #8
    Thanks, that is exactly what I meant (perhaps my description was bit unclear). So every button is drawn according to the Person object that is stored with in the NSArray. Instead the button does not store an entire Person object, but a tag, for example the ID of the Person object.

    So that I may use the tag/PersonID to show the right person's information. Do I get it right there?
     
  9. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #9
    Yeah, sounds good.
     

Share This Page