UITableView inside UIScrollview Horizontal Paging Programatically - objective-c

Good day,
I have a question about programmatically adding UITableView inside UIScrollView. The structure is like that:
UIView
UIScrollView
UIView(contentView)
UIImageView
UITableView
How can I add the UITableView programmatically inside UIScrollView so when I scroll horizontally to switch between UIImageView and UITableView. Note I am using Autolayout so I need to add constraints also. If it is going to be easier with storyboard please let me know how to do it with storyboard instead of programmatically

I used SwipeView it is pretty easy to use 5 minutes installation and did what I was looking for.

Related

Navigation Buttons + UICollectionview on same controller?

I'm newbie with iOS and asking for direction.
I want to make a page which contains navigation buttons on top and when tap load different UICollectionView's as you can see on the app screen taken from "Fancy". Also buttons line have to be fixed on top while scrolling down. (just like in the screenshot)
Which is the right approach?
Base class to be UICollectionViewController and adding as SubView
Using UIScrollViewController?
etc...
Thanks in advance.
Base class should be UiViewController implementing UICollectionViewDelegate
UIViewController <UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>
Create different NSArray for each Category of your project as datasource of UICollectionView
use UISegmentedControl for switching the datasource of UICollectionView and reload UICollectionView to display different content.
You can customise your Segmented Control as you wanted.
Implement UITabbarController for the bottom bar to enter any other views
There are a number of ways to go about this. The simplest would probably be to use a UIViewController subclass whose view contains a UISegmentedControl subview (for the navigation controls) and a UICollectionView subview for the content.

IOS How to automatically rezise its subviews

I am using IOS 5. I am a very beginner in IOS. In my project i have 2 xib files. One is a UIView and other is a UIViewcotroller. The UIViewcontroller is having 3 views(TopBar,ContentArea,BottomBar). uiview also has 3 subviews. I added UIView as subview of UIViewController. My requirement is change the UIView height when i hide topbar only, bottombar only, topbar and bottombar.
Hope you can help me.
Thanks in advance.
set the views as properties,
#property (nonatomic, retain)UIView *element1_p1;
then when you need to change the size, change the frame,
self.element1_p1.frame = CGRectMake(center.x,
center.y,
elementWidth, elementHeight);
I recommend doing an animation for the change of height, so it feels better UX
great tutorial for changing views properties with animation
UIView has method as setFrame to resize the view.
Read this and this - you will get an idea how subviews respond to parent view's frame changes.

Xcode - When to use a UIView or a UITableView?

If I want to list some items from a database, do I need to add a UIView and a UITableView to my ViewController? or just add the UITableView to my ViewController?
You must already be having a UIView as part of your ViewController, Just add UITableView as a subview to your UIView.
The UIView of a ViewController can be accessed as [self.view];. So what you need to do is [self.view addSubview:yourTableView];. Using setFrame properly sets it in the x,y,width,height that you need.
Just add the UITableView cause you are already have a UIView, Please check this tutorial on how to use UITableView.
its just depend on your project layout if you want to add tableview then you can use predefined function like didselectrow,moverow,editingrow,willdisplay etc...it totally depend on your need and layout specification and last thing tableview is better than using view instead on another view.

Rotate UIViewControllers in UIScrollView

I have UIViewController with UIScrollView in it.
UIScrollView contains multiple UIViewControllers (something like PageControl Apple example).
Each inner UIViewController in UIScrollView is able to handle the change of UIInterfaceOrientation and to redraw it's view.
But when the UIViewControllers are in UIScrollView the rotations events never reaches inner UIViewControllers.
How can I make those inner UIViewControllers to handle rotation events?
Thanks in advance.
Only a viewController in a viewController structure (like tabbarcontroller or navigationcontroller) gets (and handles) rotation events. If you just added the views of some viewControllers, they won't actually rotate, but they will change their framesize accordingly to the new size of the main view. In general you should use autoresizingMasks on every view. Read about them in the documentation.
But in a scrollView there is probably no autolayouting possible. You could overwrite layoutSubviews: in your main view to handle the layout of all scrollView subviews based on the scrollView frame.
Perhaps you can detect when the device is rotated, then using the transform property apply the necessary rotation programmatically using CGAffineTransformMakeRotation(-M_PI_2), for example...

UITableView in a UIScrollView - How to make the view scroll, but not the TableView in itself?

Imagine, there is a UIViewController with a UIScrollView in it. At the top of the view there is an UIImageView, some UILabels and other things. Furthermore, there is a UITableView which content is Dynamic Prototypes. I attach a picture to make it clear:
I haven't got a static amount of cells in the UITableView so it could be scrollable. My problem is the following: the UITableView scrolls in itself but I want to scroll the whole View. What is the best possibility to do that?
Possible solutions I've founded today
1) The first thing is: I create a UITableViewController and declare a header section in which I include all my labels, images etc. programmatically (I would love to use the interface builder for that...)
2) Another solution is to calculate the height of the view. I tried the best to do it like this way - but: without success. If this is the best way to do that: Can anybody give an example?
I would ditch the UIScrollView and just use a UITableView. You can add a UIView object as the tableHeaderView of the UITableView just by dragging it in in Interface Builder. Now since everything is part of the UITableView hierarchy, everything will scroll together as expected.
You could also try setting delaysContentTouches to NO on your scrollView. Depending on your setup, this may make the scroll view respond to the touch first instead of the table view.
From Apples UIScrollView Docs:
delaysContentTouches
A Boolean value that determines whether the scroll view delays the
handling of touch-down gestures.
#property(nonatomic) BOOL delaysContentTouches
Discussion
If the value of this property is YES, the scroll view delays handling
the touch-down gesture until it can determine if scrolling is the
intent. If the value is NO , the scroll view immediately calls
touchesShouldBegin:withEvent:inContentView:. The default
value is YES.
You'll have to (as you've mentioned) add the UIView containing the image and buttons to the actual UITableView. Embedding it in the scroll view will produce the undesired behavior that you're seeing.
I would recommend returning the UIView as the header view for the first section of your table view. You can do this by implementing the UITableViewDelegate method:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;
If you maintain an IBOutlet to the view containing your image/labels, you can return it here.
this is same demo i hope its helps you from iphone sorce code library
http://developer.apple.com/library/ios/#samplecode/iPhoneCoreDataRecipes/Introduction/Intro.html
thank you