This question already has answers here:
How to display multiple columns in a UITableView?
(6 answers)
Closed 10 years ago.
I'm creating an iOS app and will to create Table view cell with 3 columns inside of it. For example instagram profile page that contains the user information. Can this be achieved within xcode? I'm using a storyboard.
Yes it is very much possible in XCode. You'll have to create a custom UITableViewCell to create this. In your custom UITableViewCell you'll have to create different components as per your need.
I believe the yellow box in above pic is what you want to achieve. For this :
You'll have to create one custom cell with 3 UIImageView
EDIT :
In your UITableViewCell you'll have to create one UIImageView to show the profile picture.
Two UILabel one for the statistic. And, one for text.
One UIButton for Following.
How About the UICollectionView instead UITableView.
Create a custom cell.
You can either create the cell in interface builder or subclass UITableViewCell and overwrite its initWithStyle and layoutSubviews classes. You can access their properties within cellForRowAtIndexPath as usual. You could even do the layout in cellForRowAtIndexPath but I would not recommend that simply because of its bad style. For the user there would not be any difference.
Related
I need to show results of quiz which contains question text label and dynamic number of answers (Label + UIImage).
Which way of doing it is the best? Adding a tableview inside tableview? Or anything else?
You can just add a dynamic UITableView with a prototype section and a cell in a UIViewController each section has the question title in it and inside each section cell put a UIimageView & UILabelfor the different answers.
Don't forget your delegates and datasources plus create a UITableViewCell swift file to add the IBOutlets of the UIImageView & the UILabel. If you need a sample code i can provide you with one if you didn't really understood what i mean. But if you played with tabelViews before you will be able to do it easily.
This question already has answers here:
How to display multiple columns in a UITableView?
(6 answers)
Closed 9 years ago.
Is it possible to create multiple columns in UITableView, as my requirement demand me to do this, If it is possible how i can i resolve this issue.
Thanks in advance.
You may use UICollectionView for that. Or simply build each UITableViewCell with needed labels and elements in cycle with columns count
First thing you need to do is take a look at UITableViewCell Documetation and Read the Content given there. If you read it properly, you'll get the Answer in the form of these Steps :
Create Custom UITableViewCell with UILabel equals to Number of Columns.
Use this UITableViewCell in your UITableView.
Fill each Row of UITableView with your Database Table Rows.
Tutorials to Integrate custom UITableViewCell :
Creating custom UITableViewCell from XIBs – step by step tutorial
Crafting Custom UITableView Cells
GoodLuck !!!
If you will use CustomCell there will be scrolling issue. So the best way to do this is UICollectionView for ios6. I did it with CustomCell also so if you are working for ios5 I will guide you.
This question already has answers here:
Where is a good tutorial for making a custom UITableViewCell? [closed]
(6 answers)
Closed 9 years ago.
i am new to Iphone development, i want create a tableview that contains cells of different width, like iphone contacts app when clicked on add button a tableview appears having different sections and cell are different width compared to first and second sections.
any sample code for doing this.. ?
The different sections is a function of the tableview with UITableViewStyleGrouped. The different width cells are not individual cells. Each row is a tableviewcell. Each cell can be customized to look at any you want. So 1 tableviewcell can have 3 fields in it, like City, State, and Zipcode.
Google is your friend for the sample code.
J
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to access multiple buttons in access function?
I have two different buttons in the same cell in a TabelView (which has 10 rows each with 2 buttons) both set to 20% opacity. One called "button1" and the other "button2". When "button1" is clicked I run the action "button1clicked". In "button1clicked" I set the opacity of button1 to 50%. I need to set the opacity of button2 to 100%.
So I need to somehow be able to get a reference to button2 in the same cell as button1. I can get a reference to the cell via
UITableViewCell *clickedCell = (UITableViewCell *)[sender superview];
How can I use this or any other way so I can set the opacity of "button2" via something like
["somehow reference button2" setAlpha:.5];
Thank you!
Your problem is that you seem to be violating MVC by overcomplicating your code. In the UITableViewCell subclass, make those buttons properties (if they aren't already), and implement the actions that set their opacity within the very same Table Cell class, no need for anything else. If you need to interact with other objects, make them delegates of the cell.
I would rather create a subclass of UIView as the content view of table view cell. Then you can handle the opacity change inside the UIView.
I like the subclass solution, but the other traditional solution is to set the tag property for your two buttons you add to your cell and then you can retrieve later them via viewWithTag method.
I have a custom-subclassed UITableViewCell which will include a few labels, to which I want to add some checkbox functionality. One question label and five options are multi-selectable in that UITableviewCell subclass
Since I'm already in a cell, is it possible to use UITableViewCellAccessoryCheckmark to imitate checkbox functionality? Another option would be to navigate to another tableview using UINavigationController, but I want the user to see the options in the same page.
Also, since I don't know the number of options beforehand, is it possible to design this custom cell using a XIB and yet still dynamically add some items (for example UISwitch, or UIButtons) at runtime? Or do I have to code it all without using a XIB?
In short, Yes.
UITableViewCell is a subclass (somewhere down the way) of a UIView. That said you can insert a UITableView in it and create your checkbox allike cells. Think of it as nested tables:
Table of questions -> question cell -> table of answers -> answer cell.
So what you want to do is to make your custom UITableViewCell implement UITableViewDelegate and UITableViewDataSource then you want to insert an UITableView in the IB.
When you want to show your question cell with 4 answers you would pass a parameter of answers as a NSArray to the custom UITableViewCell. It then will use it to create inner cells that will behave as answer cells.
Hope that helps.