Add UITableView to UITableViewCell Dynamically - ios4

I wanna add a UITableView to UITableViewCell dynamically, when i click on the UITableViewCell, it will change it's height and display a UITableView inside it, and when i click on the UITableViewCell again, it will hide the UITableView.
To do that, i did the following:
Create a custom UITableViewCell with a nib file.
Load it to the main UITableView with adjusting the information i wanna display it before expanding it.
Implement the - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath to handel the selected UITableViewCell.
Initiate the second UITableView (it's a UITableViewController, created it with a nib file), resize the selected UITableViewCell to fit the new size (expand it's size).
Adding the UITableView using [selectedCell.contentView addSubview:desc.view];
Reload the main UITableView.
BUT, it didn't work, all i've got is an empty space with a correct size. i've used [tableView addSubview:desc.view]; but it's add the UITableView inside the main UITableView, not inside the selected cell.
Note: the added UITableView is not scrollable and when i click on one of it's cell it will navigate me to another view.
Any hint will be appreciated.
thx in advance.

Like sosborn said, i used a UITableView instead of UITableViewController and added the new table view in
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
cause i was calling the [tableView reloadData] every time the user select a cell.

Related

Gap beneath UINavigationController toolbar when in UITabBarController

I Have a UINavigationController inside of a UITabBarController. I have the tabbar on my UITabBarController hidden. When I show the bottom toolbar of my UINavigationController, it doesn't appear on the bottom of the screen. Instead there is a 49 point gap beneath it. If I don't put the NavigationController inside of a TabBarController, there is no issue, but I need to put it inside of a TabBar.

Insert SubView in TableView's Rows

I have made my UI through C# and not using xcode.
I have added a UITableview to my view(mainscreen) and want to insert a subview to each cell of the table.
The issue is i cant access the rows individually?
How do i fetch the row index number and add a subview to that row?
Use UICollectionView and custom cell subviews. Closest thing to flow layout if done correctly.
Or return custom UITableViewCell cells for the CellForRowAtIndexPath delegate calls.
(C# is GetCell() on tableview datasources)
You need to experiment with designing the views in xcode, and learning about springs and struts or auto layout tactics used in iOS.

custom UITableViewCell accessory not positioned correctly

I have 2 custom cell in a grouped style table. The one loaded form xib positions accessory view correctly the one created with storyboard does not, although I think it has more to do with dimensions of the cell. See picture:
EDIT: it is irrelevant if accessory is set in the code or if standard accessory is specified through IB
Any ideas why this could be happening and how to fix it?
In custom cell overwriting layoutSubviews and doing something like this seems to be fixing the issue.
However I am still not clear and what the x offset is supposed to be adding 10 gets it close, but what is it actually supposed to be? How is offset is calculated based on height of the cell?
- (void)layoutSubviews {
[super layoutSubviews];
self.accessoryView.frame = CGRectMake(self.accessoryView.frame.origin.x **+10**,self.accessoryView.frame.origin.y, self.accessoryView.frame.size.width,self.accessoryView.frame.size.height);
}

TableView not showing refresh data from web Service

I have two classes FirstViewController and SecondViewController.On FirstViewController i have TableView and UIBarButton named 'Change City' .TableView is showing parsed data from the server. But when i click on Change City ,It flip us on SecondViewController.
On SecondViewController we have also a TableView which shows the cities and done button.After selecting the city we pressed Done then SecondViewController again flip to FirstViewController.
i Stored selected city in appDelegate for accessing it on the FirstViewController.
Here Tableview of FirstViewController should have been refreshed but it showing the same data as it was showing earlier.
Please somebody help me to fix this problem.I am doing this from last 2 days.
you need to add this line- [tableView reloadData]; to the method that is called when the view controller is set back to FirstViewController, which would be the viewWillAppear:/viewDidAppear: methods.Hope this helps...

Differentiate between no selection and selection at index 0 in UITableView

I have a UITableView and a UIButton. When the UIButton is pressed, it prints the text of the UITableViewCell that is selected to the console output.
However, when no selection is made on the UITableView, it defaults to row 0, and displays this text.
How can I determine if there is no selection made, so that I can bring up a UIAlert?
Perhaps you can try storing the index of the cell when the didSelectRowAtIndexPath: method triggers. That way you can keep track of whether the user has selected a row since the view has been shown

Resources