How to add an UIImage above UITableView - iphone

Can anyone please tell me how to add an UIImageView above UITableView?
I have tried adding refresh control custom view still I am not able to get the exact thing which I wanted.
For example check the LinkedIn iOS App's side bar and try to pull down the content in side bar. Please check the link and see the LinkedIn logo in the image.
http://i.stack.imgur.com/JpAjL.jpg

There are 2 ways you do this based on your requirement:
If you want to add have the image view always showing on top of the table view. If you are looking for this then please implement below method and return your image view added into a UIView for section 0.
(UIView *)tableView:(UITableView *)iTableView viewForHeaderInSection:(NSInteger)iSection
If you want image view to be hidden on table view load and show it on pull down of the table.
For #2, add your image view with frame having Y value (0 - height of the view). Then adjust the contentInset of your scroll view.

Related

UIView Follows UIScrollView

I am trying to make an app which has similar functionality to Apple's App Store Today Article controller. Basically, as you can see on the sample gif below the scroll view's content is below the header image. So I am trying to figure out how to make the image follow the scrollView below it, without being added to the scroll view itself? Is there a simple way of bonding image to scroll view? Thanks!
https://gph.is/2LKWBBZ
The image on the top could act as the header of the tableView or collectionView that would automatically scroll when you interact with the UITableView / UICollectionView.
You could start looking at ParallaxTableViewHeader and CSStickyHeaderFlowLayout to see how it works. Note: above controls use this header with UITableView or UICollectionView, but you could do the same with the scrollView with or without any modifications.

Scroll content over fixed background image in swift

I am trying to achieve a scrolling over a fixed image, as you can see on the picture.
I thought I should use a scrollview but I didn't quite get it how to use it and what to include into the scrollview, since the image and the button on the bottom should be fixed. In addition, the content should only be scrollable, when the text is to long.
I think the best solution here would be using a UITableView inside a UIViewController.
You can then set up the cells to make it look exactly the way you want.
For instance the first cell would just be the image, the second cell would be your title, the third one would be your menu bar, and so on.
This may be really useful if you plan to present dynamically the elements inside your UIViewController (for example if you need to use a database, you may want to animate the insertion of the rows only if the content has be downloaded already)
So using a UIViewController, you can just add the UITableView to it and set it up using contraints so that it fills the entire view. Then you can just add your button on the top of your table view, as a subview of your UIViewController's view (not as a subclass of your table view otherwise your button would end up scrolling too).
And again here you would need to add a few constraints to your button to make it look alright!
Just try it like this and let me know if you have any difficulties in the implementation :)
It is very complex to explain, To understand you must know good autolayout
To achieve that you need two scrollview and little math :)
Suppose your headerview height is 200
As you know when using autolayout we need following view hierarchy
Your view Hierarchy should be
--> Main View
--> ScrollView
--> Container View
-->Your HeaderView (200)
-->Content View (Equal height to UIView)
--> UIView (Your tabs like button , followbutton)
--> ScrollView 2
--> ContainerView
-->Subviews
Scroll view 1 Will used wo scroll the headerview and second scrollview will used to scroll other content of scrollview (Like Tab and text content as shown in picture )
Content View (Equal height to UIView) will allow your content view to give height of 200 extra to scroll bottom and your second scrollview will scroll to top which will allow to scroll your other content too
https://media.giphy.com/media/a2A4AQeAIkAhO/giphy.gif

pop up detail view out of tableviewcell

I am working on a app where I want to expand a tableviewcell to cover almost all the screen with animation when it is selected by user. I am looking to create a uiview on the tableviewcell and expend it to cover major portion of the screen when user selects the row.
The main problem I am having is to get the frame from where my pop up view will start expending. How will I get the frame of the row which is touched?
Thanks
Pankaj
Is it crucial that the cell should not reposition?
If not ( i am guessing not, as you are anyway planning to cover whole screen):
When the cell is selected, scroll the cell to top (using scrollToRowAtIndexPath) and either insert your custom view to cell's contentView or modify its parameters if its already there with different opacity/size etc
Use UITableView function to get the rect for the row by passing the its NSIndexPath.
- (CGRect)rectForRowAtIndexPath:(NSIndexPath *)indexPath

Scroll the entire page with with UITableView that doesn't take up the entire screen

The only UITableViews I have worked with thus far are sized to fill the entire page.
I'm trying to create a page in my app where I will have an image and a label on the top of the page followed by a UITableView to hold comments below it.
Something like this springs to mind: http://www.inquisitr.com/wp-content/fbb.jpg
My problem is if I add a UITableView below the image and label, when I scroll the tableview then only the UITableView cells scroll. Not the entire page.
How would I go about making the entire page scroll so that the label and image scroll off the page and more table cells appear?
Thanks.
Put your image and label in a container UIView, and then set that container to the tableHeaderView property of your UITableView.
You could try setting the tableHeaderView property of the UITableView to a custom view containing your controls.

How to decrease width of table view cells for iphone

I'm trying to create a grouped table view with two sections. For the first section I would like the width to be only half the screen. For the second section it would be the standard width. Also, next to the first section I would like to put a button.
How is this done?
Thanks!
To put a button in a section what I've done in the past is create a section that has no rows in it. Then, I respond to the - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section method with a view that contains a button that is rigged to whatever delegate I need. This will give you the appearance of having a button sitting in a section with no data. This is how buttons appear in the Contacts view/edit screens in the stock iPhone apps.
Table view sections are fixed with to the size of the screen. If you want the individual cells to appear narrower in one section and wider in another, then you can control the size of the view itself with the data source delegate, though you might have to set the background of the table view to transparent so users can actually see the smaller view on top of the table view.