How to adjust multiple views based on json response - iphone

I have an image as attached. Based on the JSON response, I have to hide/show the views.
For eg: In the attached image, if "Mobile Lines With No Usage" is not there in JSON response, the view should be hidden and get adjusted in the view.
Similar to the image attached, I have 4 views in total in the ViewController with multiple subviews inside each view.
So basically, based on response I need to show/hide and adjust the views accordingly.
Is this possible?

Related

Creating tableview cell content programmatically

I want to create UItableViewCell ui programmatically based on API response.
I'm using a API that output a set of articles, but the content of these articles could be deferent, for example some articles may not have a description, or some of them may not have a image. I want to create Tableview cells programmatically based on these data.
I have tried setting constraints in viewDidLoad method of the cell but It does not work.
Do you have any suggestions on how to do this?
Depending on how different the articles are from each other, you could either choose to design multiple different kinds of cells for your table view and choose which cell to use for a given row based on the data you have, or you could design a single cell that uses a stack view to hide the labels that you don't have data for. When you set a view inside a stack view to isHidden = true then the stack view will resize its subviews as if the hidden view does not exist.

Two UICollectionView inside UITableView not UITableViewCell

I found this post here : http://ashfurrow.com/blog/putting-a-uicollectionview-in-a-uitableviewcell/
But,unfortunately,this doesn't meet my requirement.It was here.
My flow is similar to the one at App Store.But,What I am gonna do was implementing pull to refresh and pull up to load more at top and button of UITableView.
I can include both two UICollectionView at the UITableView.But,I can't resize second UICollectionView as the data included in its datasource.
Please take a look
As you can see there was 5 blue block at second uicollection view.But,they are not showing properly.Its there anyway that i can fix my collection view data by resizing uicollectionview?
Because second collection view data will be dynamic as soon as I implement pull to load more below at uitableview cell.So,i disable the second collectionview vertical scrolling.But,I want to appear all the items at second collectionview.
Any Help?I can provide sample if needed.Thanks.

UICollection View Cell Displaying Incorrect Data

I have a collection view which is setup with a UIPageControl. Each cell is one screen. Each cell also contains a table view, which has a header view that displays an image. Each page/cell has a different image. I set the size of the image view to be the size of the image, so each page's image view/table header is a slightly different size.
When scrolling the collection view, however I find that some of the pages are not displaying the correct information. The table view contents were of a previous page, as well is the image and it's size. Essentially, it is not calling my method which sets up the cell. I think this might be because of reusable cells but I don't know how to fix it or turn it off, as I haven't used collection views that much
Please Help
Thanks

UIImage - How dow I keep track of an index?

I have started creating a simple product image carousel.
It basically comprises of 3 visible UIImageViews' and 2 hidden UIImateViews'.
The UIImageViews are populated with images from an array and animate to give the appearance of of a carousel.
My next objective is to determine which product the user taps and push a detail view onto the stack.
My question is how should I determine which product image was taped?
The complication comes in, in that the UIImageViews switch positions during the animation and are populated with different images as the users "Scrolls".
You can use the tag property of UIView to give the image views an identifier to recognize them by.
For example When you set image1 to imageView1, set the tag of imageView1 to be 1. If you set image500 to imageView1, set the tag to be 500. When an imageview is tapped, check it's tag to determine which image was tapped.

Dynamically loading hi-res images into UIScrollView

I've been looking into creating a gallery mode in my application.
The functionality will be identical to the built in Photos App.
Here's the flow:
1. You touch on a thumbnail and ...
2. a modal view displays a large detail version of the image
3. You have the ability to scroll horizontally through all the images in the gallery while in this modal view
I'm stuck on step 3.
How do I dynamically load hi res images into a scroll view? I understand I need to set the contentSize for the the scrollView but how do I do that when I've only selected and loaded one image? What delegate methods do I need to implement and what does the heavy lifting look like?
Thanks in advance!
Refer to the following example project from apple, it shows how to use a scroll view to scroll horizontally through some views, u shouod only need to change the conents of those views to contain ur images http://developer.apple.com/iphone/library/iPad/index.html#samplecode/PageControl/Introduction/Intro.html