I am not able to view the section index titles in the index area of the table view. I have used the same code but its working in ios 6.0 but not working in ios 7.
I have tried the following:
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
if (isContacts) // contacts button is pressed
{
return indexArray; // return the section titles as indexes.
}
else
{
return nil;
}
}
Thanks.
#Raj I know this response is coming late but it might help others. The issue could be the size of your view. I had the same problem which had me scratching my head only to realize it was a width problem with my view. Reducing the size of the view during testing showed me my index.
Hope this helps someone!
Related
I have to implement view like this in the picture:
That view should have cells which contains expandable content views (number of that views is unknown in advance). When some view hasn't got any content, they shouldn't be expandable.
I don't have much experience but I have some idea but I don't know if it's a good solution:
I want to make table view which prototype cell have container view which refers to another table view.
Do I go in this direction?
Or, is there a better solution?
Thanks in advance.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return noOfSection;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section == 0) {
return noOfRows1;
}
else if(section == 1)
{
return noOfRows2;
}
else if(section == 2)
{
return noOfRows3;
}
else
{
return 0;
}
noOfSection = how many you want take section
noOfRows1,noOfRows2 and noOfRows3 are numberOfRowsInSection
You won't be able to do it as UITableViewCell's cannot contain Container views. Following exception will be thrown at run time:
Illegal Configuration: Container Views cannot be placed in elements
that are repeated at runtime.
Putting container views in table view cells is way too heavy. Table view cells should be lightweight so the user can scroll through them quickly. It's not necessary to put the entire view controller in each cell. The cell should just represent some of the data for that row.
And I forgot to answer your question in the title:
It is a bad practice to use container views inside UITableViewCells. It will immensely impact performance and memory of the application.
I'm trying to use PFQueryTableViewController but I can't get to minimise it so it won't take over the entire screen (top to bottom).
My main goal is to place in a tab controller so one of the tabs will display a table - but even after adding a title the table is still under the title and not just below it (first record is hidden...)
Is there a way to manipulate it a bit? All the videos I could find ended up with a full screen table - which is cool to have in 2 minutes but it's not usable at all.
Thanks!
By using:
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
if (section == self.objects.count) {
return 0.0f;
}
return 65.0f;
}
I was able to arrange the table layout.
I've got a problem in that I cannot get my UISearchBar to scroll underneath my UINavigationBar.
-(void)awakeFromNib
{
[super awakeFromNib];
self.tableView.tableHeaderView = self.taskSearchBar;
}
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
return self.taskSearchBar;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 44;
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.tableView.frame = self.view.bounds;
// Load our table with current data
[self.tableView reloadData];
// Tuck UISearchBar under navigation bar
self.tableView.contentOffset = CGPointMake(0, self.taskSearchBar.frame.size.height);
}
I've spent a LOT of time searching through SO to try to find relevant discussions.
This one, for example, makes it sound OH SO SIMPLE: Scroll UITableView so that the header isn't visible
I was previously able to get this to work when creating everything from Story Board, but I can no longer do that due to the nature of my app - I had to break things out to have a parent UIView to the UITableView which I was unable to do while using a UITableViewController.
Any help on this would be MUCH appreciated!!!
You are assigning the search bar as the tableHeaderView which will be what you need I think. BUT you are returning it as a section header for every section which is not logical(I guess you need this search bar show only in one place). Section headers are always visible and that is what's causing your problem I think.
I want to implement the Tab View like Apple has in their Apple Maps when you select a location and tap on the more details to reviews additional information about that location.
What would be the best way to implement this or how do you think Apple has implemented it. I know each tab view has a Table View inside each. Also for the Photos tab how do you think they implemented the content inside that tab. Was it using UICollectionView or a table view with a custom cell that has 4 photos in each cell row?
It looks like they're using one UITableView and on UISegmentedControl. With this combination every time the user selects and index on the segmented control, it changes a condition in the table's datasource and reloads the data. Here's an example of what something like that could look like to conditionally change the number of rows in the table
- (IBAction)segmentValueDidChange:(UISegmentedControl *)sender
{
NSLog(#"%d",sender.selectedSegmentIndex);
[self.tableView reloadData];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (self.segment.selectedSegmentIndex == 0) {
return 5;
}
return 10;
}
I'm doing something which looks like the list of notes of the iPad Notes app: a classic table view, but with a corner at the bottom, like this:
So in order to view the bottom of the list, the scroll view is kind of special.
What is the best way to do that?
Thanks a lot.
I think the easiest way is to set a footer height for your last section using the heightForFooterInSection.
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
if (section==[mySections count]) {
return 120;
}
return 0;
}