How do I implement a UITableView that can scroll over a background - iphone

I'm trying to implement a tableview where the tableview cells can scroll over a background similar to the way the facebook Poke app works. Are they using a custom uitableview or implementing the interface with a uicollectionview?

Create an UIImageView with your background image. Then set the table view's backgroundView property to the image view. This approach works well with a plain style table.

You can give the table view and the cells a clear background color (in IB or code), and give the window a background color -- you can use colorWithPatternImage:, if you want an image in the background.

Related

Matching UITableView and UIViewController background colours

I have a UITableView in a UIViewController. I'm trying to set both backgrounds to the same colour but despite both background having identical RGB values, they end up displaying a slight mismatch - see image below.
I have tried setting the UITableView background colour to clear as well but this has no effect either.
Any ideas why this might be occurring?
Make sure to set the background color of tableView like below
I would also recommend you to debug via Debug View Hierarchy in XCode to see which view has what color.

How to set UITextView's content inset like Notes App

I am working in an app in which I need to give feature like Notes App in iphone. as shown in first screen shot , initially , notes leaves a tab before the content starts, I also wanted to do the same and for that when I set Left Content inset (of UITextView) by 25 , it shows like in screenshot 2, here you may see the image also gets shifted. I have set image as background. I don't know how to solve this problem.
I also tried by adding image as subview of UITextview but it won't repeat the lines, while scrolling (image of lines) like notes app.
I'm setting the background of Textview by following code.
[textView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:#"line_image.png"]]];
Please tell me if I am going wrong or any extra effort needed to get desired output.
Thanks
UITextView is UIScrollView subclass so all relevant delegate method are available for you (e.g. scrollViewDidScroll:) - you can adjust your custom background in that method.
There's very nice post on Dr.Touch blog about recreating Notes app interface - you can get general idea about how it is done from it. Basically what is done there is adding custom view that draws background behind the text view and adjust it in text view's delegate methods and also using KVO on its 'contentSize' property.
#Dinesh gave nice solution but it doesn't sound to be generic as I want to use image of lines instead of drawing them. Image has some special effects that can not be achieved by drawing. So to solve it I created a table view below the textview keeping textview's background transparent. Now just added the image of line to my tableview's custom cell and set content offset of UItableview same as of the scrollview (subview of text view ,refering to the answer of #Vladimir ) .
And used the following code to scroll my tableview with scrolling the textview and got the desired output.
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
tableView.contentOffset =scrollView.contentOffset;
}
Keeping my tableview's number of rows at a very large number.
PS: instead of setting the content inset of textview, i set its frame's X position and decreased the width relaively.

iOS - Display UINavigationBar drop shadow behind UITableViewCell

I have followed the answer provided here to create a drop shadow for my UINavigationBar. However, the shadow is above the UITableCell that is directly below the bar (image). How would I go about making the cell cover up the shadow, so that the shadow of the bar is only visible if you scroll up?
The simplest thing you can do is to create a background image using Photoshop (or a similar application) leaving 44px (88px for the retina display) from the top and making the shadow start from there.
Then just use that as a backgroundColor of your window.
The NavBar in the image will be covered from the actual navigationBar and only the shadow will be visible (beneath the tableView as you asked.)
I dont know why you want to make the shadow only visible if scrolling up, but may be you can set UIScrollViewDelegate to the table view and deal with the event when the table view scrolling up and set shadow of navigation bar, remove shadow when scrolled to top.

Filling a UIScrollView w/ PageControl within a view

I'm trying to create a paginated UIScrollView within a view that only scrolls horizontally and is populated by labels.
There are 4 labels and each label shows a string derived from a NSDate, with each one being linked to a PageControl to show which page the user is on.
I'm having a little trouble trying to figure this out based on sample code and other answers.
If I've already dragged out the dimensions on IB, do I still need to specify the frame and such?
Do I then have to create views with labels on them? Or can I simply create labels and populate the UIScrollView?
Is there any way to get the background of the UIScrollView transparent?
You can add UILabels directly to the scroll view as they are a subclass of UIView. If you have already specified the size and position of a view in IB, you do not need to do it again programmatically, although you may. myScrollView.backgroundColor = [UIColor clearColor]; will make your UIScrollView transparent.

Setting up the (right) views in order to show an image, the details of it beneath it and enable zooming for the image

What I am trying to do is to present an image at the top of the view and beneath it to show the details of it.
By now I am using a UITableView and a UIImageView. The UIImageView is at the top of the View and the UITableView beneath the UIImageView. In the UIImageView I load an image and I want to let the user to pan/zoom it. In the UITableView I show in sections the details of the image. Everything works ok, but when I enable zooming in the UIImageView the image covers parts of the tableView. Moreover, I cannot scroll anymore.
What is the correct combiantion of views for achieving the above requirements?
Instead of the UIImageView I'd use a UIScrollView with the UIImageView embedded in it, this will allow you to setup pan/zoom within whatever view size you want.