Adding a badge or icon to a uicollectionviewcell? - ios7

I found this on stack:
How do I display the standard checkmark on a UICollectionViewCell?
But I'm a little confused on how to implement it. (I need 50 rep to ask in the comments)
I'm building a collection view where it displays a grid of images and adds a tag/badge/icon to the cell based on a variable in SQLite3?
How can i make this happen? thanks!
Keith

Related

Custom Background Image on Grouped UITableView

How would I go about setting a custom background image for a UITableView. The wrench in the works is that the table is a grouped style (rounded top corners for the first cell and rounded bottom corners for the last cell). I would like do this as much in code as possible without relying on images too much.
Ideally, here is the solution, but I have no idea if this will work or not:
Create one custom background image
Apply the same custom background image to every cell
Rounding occurs automatically because it is a Grouped table style
Profit.
Is this how it works (besides the profit part... I am an app developer, after all)? Do I need to re-think my approach or is this possible? How would do what I described (or another approach) in code specific to iOS 5+?
Update
Just to clarify a bit, the main question I'm asking is: Does the rounding still occur on the top and bottom cells even if you are using a rectangular image?
Well I think what you are saying is ok, but I suggest creating a unique cell layout in a .nib file and apply there the background. Then, with initWithNibName you can manage every cell at the UITableView's methods on the ViewController.

Passing in the chosen color variable from UIButton to another view

I am coding in the latest xcode in Objective-C and I have been pretty much stuck last two days.
I am making an application that will allow the users to select what color clothing they are wearing. So for example, if I am wearing a black and white shirt, I can choose clothing = shirt and colours = black and white.
Here is a screen shot of how my app looks like: (everything you see here are UIButtons so you can click them and for colours, I have it set up so the colours you have chosen will highlight)
![my app]: http://imgur.com/w7kvX,o6YbK#0 "myApp"
so in the first image, you would choose your clothing and once you hit the button, the second view will come up and in here, you would choose the colours.
So far so good. But I run into some problems when I want to use the colours chosen to bring back to the first view. If I picked black and white for the colours of my shirt, I want my app to bring back that data and change the "shirt" button's background colour to change to black and white to indicate to the users those are the colours you have chosen. '
Here are my codes so far.
changeClothes.h (first view): http://pastebin.com/xPMNAnCY
changeClothes.m: http://pastebin.com/MdjMPK6r
chooseColors.h (second view): http://pastebin.com/Zb4aXvzV
chooseColors.m: http://pastebin.com/RHTxfwW5
Any help would be appreciated.
Many, many, many thanks in advance.
You could work with the delegation pattern!
Define a protocol for your chooseColors class and make the changeClothes class implement this protocol. changeClothes class then works as a delegate of chooseColors class. In chooseColors class, when a color is selected via button, call the delegate with this event! Back in changeClothes class you can dismiss the modal chooseColors controller and perform some actions in changeClothes controller according to the selected color.
More on the delegation pattern: Cocoa Core Competencies
(On the bottom you have a reference to a example project from apple)
Also please take a look at the coding guidelines for cocoa!
You named your classes wrongly, see: Coding Guidelines for Cocoa
(I don't have enough rep to comment, so resorting to answer. If it's helpful you should really give Nenad the green check mark)
Building on #Nenad's answer: have a look at the "Communicating With Objects" section of the Apple documentation. It explains delegation in greater detail.

View of scrolling images

I am relatively new to Objective-C and iOS development.
What I want to do is have it that I have an array of length 52 representing a deck of cards, with each value in the array corresponding to a card image. When a button is pressed, the card that comes out will appear in an image view (already done), as well as appear as the right most element in a horizontal scroll view.
I do not however know how to do this in Objective-C, neither the horizontal view nor the appending to the end (or right).
Any help will be much appreciated,
Thank you very much for your time.
AB
What you're looking to do is called Paging with a UIScrollView. Download the "Page Control" Sample project by apple here :
http://developer.apple.com/library/ios/#samplecode/PageControl/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007795
Think of each page in that project as another card. You can add/subtract from it whilst the program is running. You can take a look at my open source "Dollar Bets" app on github for another example here:
https://github.com/Rich86man/Dollar-Bets
Check out MainViewController

Simple slideshow in a UIImageView

I got trouble to add slideshow to my application.
Currently, I have a UIView composed of a segmentedControl.
I made ​​two "views" that I hide or display depending on the selected button.
I'm looking to make a simple slideshow in one of my two views. I made a UIImageView because it is simple to display pictures.
So I'd like to display my pictures one by one and it is possible to move from one image to another by sliding your finger to the right or left (just as in the native app "Photos").
I tried to adapt example codes from the documentation, but without succes.
So I'ml looking for help.
Thanks,
jb crestot
SO, I've actually done this and it's fairly easy. The ingredient that you are missing is a UISCrollView. My implementation did exactly what you describe (allow the user to go back and forth between a set of images).
Basically, add a UIScrollView to your View in interface builder and you will be creating the UIImage views with code (a simple for loop) and setting their images the same way. I did this safely with no memories issues with about 15 images (PNG's). There could be a potential performance issue with this message if you are working with a large number of images (say 40?)
I hope this helps, let me know if you need a code sample to see how this works.
You may consider using a custom class, such as iCarousel, linked below. Each of these views could be your image, and then tapping on them could launch a fullscreen view for example.
Keep us posted!
http://cocoacontrols.com/platforms/ios/controls/icarousel
See apple's page control sample application.

How do I make a header row with a gradient background in my NSOutlineView?

I am using an NSOutlineView in my App so i downloaded Apples Photo Search Sample App which uses an NSOutlineView. While using it I noticed that it gives the root object of the outline view a Gradient Background, so I looked through the code but I couldn't see what did it. Would someone mind looking through the code and then telling me what code gave the root object a background?
Here's the link to the Photo Search Download Page - http://developer.apple.com/Samplecode/PhotoSearch/index.html
Thanks!
OK, my previous answer is wrong. Here's the correct answer:
Be the outline view's delegate, and respond to outlineView:isGroupItem: (tableView:isGroupRow: for a non-outline table view) with YES if the item (row) is a group and should be displayed accordingly.
You mentioned in one of your comments on my other answer that you want to make every row look like a group. Don't do that; it will confuse users (“why does it have an empty group for every one of my items?”).
It's outlineView:dataCellForTableColumn:item: in MainWindowController, which returns the cell created and assigned to iGroupRowCell by awakeFromNib. (No it is not. See my other answer, and please downvote this one.)
It seems as though NSOutlineView is giving the text field cell that style automatically. It definitely is that cell, as you can tell by setting its text color to red as soon as it's created.
If I'm wrong, then I'm stumped as to how it gets that style; if I'm right, it's a really cool feature.