To show all detail when orientation changes - swift

I am using iPad to run the app. for example, when iPad place horizontally, the width is 800px and height is 300px.
Now, The UItableview can show all details. However, when changing orientation, the width become 300px and the height is 800px. It can't show all the details.
The content is fixed size and fixed width in both orientation. I don't want it to be dynamic.
My question is how can I scroll the tableview horizontally to see all details?
Is there any method to do that?

You can scroll the tableView horizontally in the following ways for solving the problem.
Firstly, take a look at this. This should solve your problem.
https://github.com/alekseyn/EasyTableView
I did this and its works fine.
CGRect frame = tblView.frame; tblView.transform =
CGAffineTransformRotate(stressTblView.transform, M_PI / 2);
tblView.frame = frame;
Another way is that you can use a UICollectionView, not a UITableView. Here you may implement cells and scroll in either direction.
In Interface Builder when you select the CollectionView it has a property called Scroll Direction. Change that to horizontal
Choose the one which best fit to you.

Related

UICollectionView or UITableView to be more than screen size

I need to display a table of data ; rows and columns. I thought UICollectionView would resolve my problem and resorted to it, rather than going in for UITableView. UICollectionView's flowLayout (the out-of-the-box layout) does indeed display more than one column of data. But can I make it display content for more than one screen width ? Say, I want the UICollectionView to display 3 screen widths of data (for example, for iPhone, it's 320*3=960px)? By default, UICollectionView's FlowLayout seems to break data display at the screen width and proceed to display the rest in the next line. Now, I don't want it to break at the end of the page-width, but at the end of (3 * page-width).
What I tried:
I put the CollectionView inside a UIScrollView and set the scrollview's width to 3*page-width like this:
[self.scrollView setContentSize:CGSizeMake([[UIScreen mainScreen] bounds].width*3.0, [[UIScreen mainScreen] bounds].size.height)];
When I run the App, the page does show the width of 3*page-width. Am able to scroll horizintally well. But still, the UICollectionView data breaks at one page-wdith and continues display un the next row (meaning it does not consider the scrollview's width as its width ; rather, it continues to consider the page-width as its width).
Kindly provide your suggestions/comments. It will be of great help!
You should be able to just change the scroll direction so the Flow Layout will scroll horizontally instead of vertically:
UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)self.collectionView.collectionViewLayout;
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
You can also set this directly in Interface Builder.

iPhone how to implement a "Wide" UITableViewCell?

I'd like to have a UITableView with cells wider than 320 points. The user should be able to scroll sideways to be able to view different parts of a UITableViewCell. Is this kind of behavior possible with a UITableView, or should I go and try to implement a tiling UIScrollView?
I tried wrapping a UITableView within a UIScrollView, and the results are terrible - they compete for the scroll gestures and most of the time the scroll view wins, preventing the table from being traversed vertically.
Any input is appreciated!
Thank you!
Update: I tried the proposed solution and it scrolls properly, but the tableview is still only 320 pixels wide. Is tableView's width linked to the window bounds ?
Wrapping the table view with the scroll view is the right way.
UIScrollView with
Show horizontal scrollers
scrolling enabled
autosize to full screen
Inside that, a UITableView
shows vertical scrollers
scrolling enabled
Then I set the table view's frame, with w, being the calculated width of the table view with all columns, whatever your width, and kTableScrollViewHeight being the fixed height of both the table view and the scroll view, in my case, for example 367 points (screen minus status, navbar and tabbar):
tv.frame = CGRectMake(0, 0, w, kTableScrollViewHeight);
and the scroll view's content size
scrollView.contentSize = CGSizeMake(w, kTableScrollViewHeight);
If you want the scroll-to-top behavior when the user taps the status bar, you might want to set
scrollView.scrollsToTop = NO;
because otherwise the scroll view will take away the tap from the table view.

How to create a horizontal transparent scroll bar?

I am trying to create something like this (look at the time), you can basically slide it horizontally.
Can anyone give me any suggestions on how to do this in iOS?
You'd use UIScrollView which you can constrain to just horizontal movement. The Scrolling demo may help to get you started.
It is pretty easy:
create a scrollview with frame of (xOrigin,yOrigin,SCREEN WIDTH,Height).
set the content size to (CONTENT WIDTH, Height).
setShowsHorizontolScrollIndicator to no to hide the scroll indicator.
Note: Width of the contentSize property should be greater than the frame width to make it horizontally scrollable.

How do i have different UITextViews on the same DetailView without having scrolling problem?

I have DetailView in which there are three textviews which are showing different informations. is it possible that on whenever i scroll down to read all information. all those textviews scroll like they are one page. i mean they look like one textview. i m doing this bcz i need those information in different fonts. and if there is any other nice approach i can use to show that information? plz tell me.
thanx in advance.
Yes, you can place those three UITextViews into a UIScrollView, set userInteractionEnabled = NO in the UITextViews, and properly set the contentSize of the UIScrollView to cover all 3 UITextField size, then they will all scroll as one unit and the UITextViews won't scroll at all within themselves. (Again: a UIScrollView will not scroll in height / width unless the contentSize property's height / width is larger than its frame property height / width).

iPhone Horizontal Scrolling Table

I need to create a view on the iPhone that scrolls horizontally through a gallery of images. The issue is that this gallery has the potential to have 100s to 1000s of images that needs to be presented, so I would like to avoid loading them all into a single UIScrollView at once and destroying performance. I need to create a view that recycles the view objects (like UITableView) to increase performance and reduce memory overhead, but it needs to scroll in a horizontal fashion.
Any ideas? Is it possible to make UITableView operation horizontally?
Thanks!
You could use a large scrollview, and monitor for the scroll position to change. You can add images as subviews as they are coming into the actual viewable area, and remove them as they are scrolled away.
This way, you only have to have a small number of image views present at any given time, but you give the appearance of them all being "there".
You could even recycle the image views by changing their image and location so you are not creating and destroying complex objects. This is what UITableView does with cells.
It is as simple as appyling a Transform.
Here is the code. Write this in the your tableViewController init:
self.view.frame = CGRectMake(100,-5,250,350); //any Frame of your choice
CGAffineTransform trans = self.view.transform; // get current transform (i.e. portrait)
trans = CGAffineTransformRotate(trans, (M_PI / -2.0)); // rotate 90 degrees to go landscape
self.view.transform = trans; // set current transform (landscape)
But now what you need to realize is that your axis are also swapped. Any changes you make to the height will change the width (and vice versa) and any changes made to the origin.x changes the origin.y (and vice versa)
I agree with mbmcavoy, you can also take a look iPhone/iPad – AppStore like UIScrollView with paging and preview this article explains what you need about UIScrollView as well as provides a good example and source code.
Regards
Is it possible to add a UITableView horizontally? In a different orientation than the screen. Then you can use regular UITableView semantics where each row is an image that scrolls horizontally instead of vertically.
Posting an answer to this old thread because the validated answer is not correct. You may use a UITableViewController and its dequeueReusableCellWithIdentifier built-in features.
The trick is to make your tableview rotate and then make your cell rotate in the opposite direction.
in viewDidLoad you will add:
self.view.transform = CGAffineTransformMakeRotation(-M_PI_2);
And then in cellForRowAtIndexPath you would use:
cell.containerView.transform = CGAffineTransformMakeRotation(M_PI_2);
Make sure that every content of your cell is added to a container view (in this example containerView) so that you only have to rotate the container and not every cell subview.
Also please note that it will work better with cells having square dimensions, cause otherwise you may struggle with height/width computation.
I think I have the answer for you About scrolling an UITableView Horizontally:
create an UIScrollView (and disable
the vertical scroll)
put an UITableView inside the scroll
view
change the table view width as you
wish and update the
UIScrollView.contentSize as the
tableView width