PFQueryTableViewController as part of a tab controller? - ios

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.

Related

Is it a good idea to make table view in container view in table view cell?

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.

Table view index not displayed for contacts in ios7

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!

iOS —Sticky segmented control like App Store app

I am creating an app and in one of the navigation views, I have a very similar design as that of the App Store app — see Details | Reviews | Related section. Following on similar lines, I wish to implement the segmented control in the 'same' way Apple has done in their app. (This is also similar to what Apple does in the Artist -> Albums navigation view in the default iOS 7 music app, albeit for a table header (maybe).)
If you scroll up, when the segmented control container touches the navigation bar, it sticks there.
It also allows the user to notice that this is some kind of overlay due to the alpha associated with it.
When you scroll down, it moves into position when required.
What I have done —
I have created a container view with the segmented control. When the scrollView scrolls, I reposition my container view to accomplish the sticky effect. This is just pseudo-code but my code actually works.
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (scrollView == self.labTestScrollView)
{
/*
As soon as the user scrolls up, y changes, therefore, we need to stick the options container view
such that it doesn't go past the UINavigationBar
Need to check if the origin of the options container view in the coordinate system of the main
superview is just gone past the UINavigationBar in this controller's view.
- get the bounds rect for the options container view
- convert these bounds and position them in the coordinates of this controller's view
- check if origin.x for container view is less than that of view.origin.y
- if less than stick it by converting the headerFrame to the coordinate system of the options
container view; and raise the stuck flag
- if greater, check if the stuck flag is raised; check for another object in space before the container view and adjust accordingly.
*/
}
}
There are two issues:
No overlay effect. I can configure the alpha such that the effect is a bit more visible but that doesn't seem natural.
The second concern stems from the first. This seems like a very specific solution. I am looking forward to something that's more natural; and something that could work by default using table views or something.
Why not simply use a UITableView?
Put your 'top content' in section 0 and have no header for that section. Put all the other stuff in section 1 and give that section a header with your UISegmentedControl.
Following code works pretty well. You might want to find a way to give the background of the header a 'blur' effect to mimic Apple's behavior some more; maybe GPUimage could help you there?
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return section == 0 ? 1 : 5;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *identifier = indexPath.section == 0 ? #"header" : #"content";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
// customize cell
return cell;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
if(section == 1) {
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:#[#"Foo", #"Bar"]];
segmentedControl.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.95];
return segmentedControl;
}
return nil;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return section == 0 ? 0 : 44;
}
I'll leave the tweaking up to you ;)
This is actually 2 views.
The first is the header of a UITableView.
This includes the segmented control and the app icon, the install button, etc...
The second view has a segmented control that sits at the top of the screen and is hidden.
When the tableview scrolls you can intercept the scroll view delegate method scrollView:didScroll...
In here, if the scrollView offset is larger than the height of the header then make the second view visible. Else make it hidden.
That's it. Now you just need to remember to update both segmented controls whenever one is hanged.

How to Implement Tab View in Apple Maps

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;
}

Table view with bottom corner like the iPad Notes app

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;
}

Resources