Display Array as List - iPhone - iphone

I have an array of scores in my iphone game. All I want is a plain list, just text of these scores.
Do I need to load this into a UITableView then somehow remove the background of the table, so it appears as just text, or is there a different method I can use to get this list as just text?
Thanks.

I think you need to better define what "as a list" means to you. You could construct a multiline string containing those values and disposing in a UILabel or UITextField but I can't tell if that would make sense for your data and your desired UI.
How many scores do you have? Will they all fit on the screen at one? Do you need to be able to scroll the list? Do you want to be able to tap on the scores? Copy them? Format them differently?
You certainly could also create a table view with a tranparent background on the table and it's cells. Just be aware that transparent cells are more expensive to render and will not scroll as smoothly as opaque cells.

Related

Swift IOS - a complex table view cells' arrangement

All. I am new to Swift. I am trying to create something similar to the image attached below. My question is regarding the table view.
I create a prototype cell for each recipe, in which contains an image View and a textfield. However, how should I arrange those cells like those in the picture attached?
It seems that each cell has a different height. I thought about including multiple recipes in one prototype cell, yet it may not be the right solution.
In the real world, how do people handle such arrangements? Maybe people use something other than prototype cell?
Your help is greatly appreciated. Thanks in advance.
You can achieve this thing by using collectionview. If you know width and hight in advance then you can simply create collectionview with constant width and height of cell. if you don't know the dimensions in advance you need to do some extra task in collectionview which is selfsizingcell.
This is called 'waterfall collection view', you can find similar thing in Pinterest app. Size of each cell is dynamically calculated based on the width&height of picture itself.
Personally I've used this open-source github project, in order to implement same thing in my app.

How to center a UIActivityIndicatorView along with text (UILabel)?

I've had this issue come up a couple times doing iPhone development now and have yet to find a good solution for it. What I'm looking for is this:
I want to show some text along with an icon and I want the overall display to be centered within its parent view. Specifically, in my current case, I'm looking to display a box that says "Reconnecting..." with a UIActivityIndicatorView to the left of the text.
Previously, I've just relied on the fact that I know exactly the dimensions of the text and activity indicator, so I can position things absolutely to appear centered. What I'm looking for is something more automatic.
Any ideas?
One of the UIKit additions to NSString will return the pixel size of the text if you give it the font that you're using on the UILabel. So then presumably the total size of the two things together in the layout you describe is:
the difference between label.frame.origin.x and activityIndicatorView.frame.origin.x; plus
the width of the text.
You can then either shuffle both the views appropriately or give them a common parent that's still a subview of the whole thing and shift that.
An activity indicator can be shown in a view just calling a single method.Please click here get SHKActivityIndicator class

Possible to reuse UILabels on a scrollview?

I'm trying to implement a view that shows a grid of information without using a UITableView, however, since I'm displaying about 36 different statistics, with its label I will have to initialize and use 72 UILabels. Does having so many UILabels mean that my iPhone app's performance will be significantly negatively affected? Is there a way to reuse some of the UILabels to decrease the number of UILabels that must be loaded at one time, or should I just resort to drawing everything on a surface instead?
First of all you should test the interface your thinking of and see if it takes a performance hit. Having a lot of labels all loaded at once will increase your memory footprint but depending on what else is going on in the app, it might not matter.
Secondly, you can't easily reuse the labels but it is possible. However, you would have to constantly monitor the displayed area of the scrollview and move the labels frames around as the view scrolled. I doubt you could do that efficiently. It would take a lot of coding in any case.
Thirdly, any grid like layout can be easily displayed in a table without making it look like a table. For example, the photopicker layout is a table but it looks like a bunch of icons on a white background. Another app I saw used a table to display paragraphs of text but it looked like an ordinary scrolling textview. Every row in a table can be customized to display exactly what you want. In principle, you could use a different cell for every row and they could all be unique in their height and contents.
The advantage of the table is the the table manages what is and is not on screen for you. It does reuse cells and their contents which makes them more efficient. The table also makes it easier to manage a lot of data.

iPhone: How to wrap text in drawRect?

How does one draw wrappped text in the drawRect method? I'm trying to use atebits' ABTableViewCell class to do custom drawing of a table view cell. I'd like to draw a small picture and then text next to it which may or may not need to line wrap. Think of the table cells in a Twitter client like Tweetie which show a profile picture and a tweet. How is that done?
I tried using the various NSString drawAtPoint methods, but they don't seem to wrap the text into multiple lines.
I think you need one of the drawInRect:withFont: methods. They are documented as performing word wrapping. If you think about it, it makes sense that drawAtPoint wouldn't work, because it doesn't know the rectangle the text needs to fit into.

How to enlarge Picker View on iPhone?

I add a PickerView to one of my views in an app, but its size is too small(in height). I find that I cannot drag to make it "longer". How to change its size then?
The only way is by adjusting the pickerView.frame.size.height, but you'll get some pretty bad visual artifacts.
I would think long and hard about attempting to circumvent the established design of this control. If you have so many items or your items are too big for this view, a UITableView is probably what you want to go with. It's far more customizable and can handle items/cells of all different shapes and sizes.