I have created on nib file. In nib file i have one table view cell, In a cell i want to create a table view. But i am facing the problem to create a table view inside the cell. Please give me any suggestion on that. Thanks in advance.
Just drag the table view into the prototype cell's contentView. You'll probably want to make a UITableViewCell subclass in order to make it easier to encapsulate the datasource/delegate methods for the sub-tableview.
It is too difficult solution.
Why can't you implement different cells in one table view?
Not use table in cell in table, just use one table with different cells.
You can use tableviewceell control in nib/xib and than you can add table view in that cell.
I have tried once.
Hope you will get your answer.
:)
Related
I have a UITableView with custom cell. I have created seperate class with xib for the tableviewcell. in tableviewcell i have added a UIView, because i want to add different uiviews in the tableview.
Now I have 2 views which i want to add based on my data to the tableviewcell. i,e; if my data support view1, then i am adding view1 in an array which will be used to draw the table view & in table view drawing i am simply writing like this:
cell.parentView = [dailyExpenseViewArray objectAtIndex:indexPath.row];
Daily Expense View array is an array of views of type 1 & 2. Parent view is the UIview object inside tableviewcell.
My problem is i am having the view array perfectly. but in the tableview, it is showing blank rows. although the number of rows are drawn, but with blank views.
Any help would be appreciated. Thanks in advance.
I'm not sure I fully understand your problem without seeing some more code, however I think it may be an issue with the way you're trying to display the UIView inside the cell. Have you tried the following:
[cell addSubview:[dailyExpenseViewArray objectAtIndex:indexPath.row]];
It is not fully clear what you are trying to do, possibly some code would help.
Anyway, if I am understanding correctly, I would suggest trying to add your views as subview to the contentView property of your cell (instead of setting parent, I mean), like this:
cell.contentView = [dailyExpenseViewArray objectAtIndex:indexPath.row];
hope it helps...
I was working with the grouped table view , and i wanted different controls for every row i.e switch control for 1st,radio button for 2nd ,checkbox for 3rd and so on.. how can this be implemented programmatically that is without using interface builder
thanks in advance
CharlieMezak said is right, you need to create in UIControls directly in cellForRowAtIndexPath , and add as subviews to contentView of the cell
For reference see the link below
http://www.e-string.com/content/custom-uitableviewcells-interface-builder
the link specifies the code to create cells programmatically as well as using IB.
Table View Programming Guide for iOS
Read the programing guide, and remember to use different CellIdentifier for each type of cell.
This is a pretty vague question.
Obviously you need to provide the cells to the tableview in its cellForRowAtIndexPath delegate/datasource method. So, either in that method or during the initialization of your view controller, build the UITableViewCell instances that you need, adding the various controls that you want to them as subviews and connecting the controls to your view controller so you can detect when they have been changed. Then just return the appropriate cell in the cellForRowAtIndexPath method.
Personally, I think it's a lot easier to use IB in cases like this. Just create an IBOutlet instance variable for each custom cell you want, and return the right cell in cellForRowAtIndexPath.
What's the best way for me to add 2 custom buttons in the header of my UITableView?
On clicking either of those buttons, a different table View is loaded.
Thanks for the help!
Add the two buttons to the header, and use the IBActions of those buttons each to set the datasource to an other array. After that, use [tableView reloadData];
If you want to use buttons above the table, I'd suggest either using sections if your having no sections in your original table, or placing a toolbar above your table.
UISegmentedControl is pretty much for this purpose, then you can hook the events and switch the views accordingly... It looks better tan two separate buttons, and also better from the user experience perspective...
Second choice is to have two different tables or one table with two different data. I would prefer two tables, each having its own data, and delegates. Easier to write cell rendering code and all...
If both data are of the same type like "Array of MyObject", then you can come away with just a flag and some ( flag ? firstDataArray : secondDataArray) type of selections in the table delegate methods.
First add two different customs button and then add two different table Views bellow that custom buttons.
Use a separate UView and add both UIButton as subview into.
Then add this button's view in the parent view of your UITableView
Then both the button's view and UITableView will be the sibling view....
I need some help.
I've got a segmented control. if segment 0 is clicked it shows a UIView, containing a uitableview.
If segment 2 is clicked it shows another UIView which contains a uitableview as well.
These two tableviews got the same datasource. But i want the second tableview to have an other datasource. SO i thougth of loading another nib into the second uiview containing a the tableview which gets its data from the corresponding .m file.
I don't know wheather this is the best solution. If you've got any other ideas let me know :)
thanks in advance!
I think the best way to do this is to have just one table view. In the cellForRow method have a conditional which queries the state of the segmented control. Depending on the result of that if statement, return the type of cell you want. In addition, in your segmented control callback you'll have to do a [tableView reloadData]
Do you know that you can have the same tableview display different data sets? You don' have to use an entirely different NIB just to change UITableViews so you can display different data. Or am I understanding your question incorrectly?
Is there any sample code that would illustrate how to have multiple images within each row?
Typical apps show a thumbnail to the left side with text to the right. I'd like to do that plus an image to the right of the text.
How would I go about doing this?
In interface builder, simply create a tableview cell that looks like you want. Then create a UITableViewCell subclass that has properties pointing to the elements of the new cell. Set the class of cell to the subclass then add cells of that class to the table in the standard way.
A tableview cell is just a view and you modify it and use it just like any other view.
You'll have to create a custom UITableView cell. Here's an example of using multiple UILabels in one. Here's another.
Pretty easy - follow Apple's documentation to create exactly the cell you want in Interface Builder with as many UIImage or whatever else you like. Look at Table View Programming Guide for details on how to make and load the custom cells - just be careful about performance when you put a lot of visual elements in a table view.