I am using the Interface Builder storyboard in xcode 4.2.1
I have already made a new .h and .m file for the scrollview.
I heard people talking about setting contentSize to something, but I don't know how to do that. Can someone help?
What I want is a simple scrollview which I can insert text and images into. And it has to scroll.
Thanks!
You have to set content size for scroll view in which your image or other view can scroll. It will be the total size of all view. You can set content size as followings:
[scrollView setContentSize: CGSizeMake(scrollView.bounds.size.width * numberOfPages, scrollView.bounds.size.height)] ;
Related
I have a weird problem: I use Autolayout for a UIScrollView with child views, and when I show the Preview everything looks fine:
But when I build the app the content is not shown correctly, seems to be an content size issue.
I pinned all of the child views correctly, didn't set any content size (as should be with autolayout scrollviews), but I can't get the scrollview work with correct content size.
Anyone that can help me on that?
Thanks!
I need to make my tableview not change height at all. Not shrink when statusbar is changed. I am using storyboard and i have another viewcontroller with a embeded tableview where the tableviews height stays the same no matter what.
In interface builder when switching from 3.5" to 4" the tableview changes size. I have fixed this by setting height programmatically. However the height changes when statusbar is changed. I cant seem to find the property in IB that turns off this autosizing feature for my second tableview. Im am not using auto layouts. I dont know why the height allways stays the same on my other tableview in my other viewcontroller.. Can someone please help me out??
Auto resize subviews was the property for the main view that was enabled . Disabling this fixed it.
I'm wondering if you can help me.
Basically we have a set of 16 images,
ImageA.png
ImageB.png ect ect...
That need to be shown by selecting it from a "Menu".
I want it to work like a split view controller, but I don't want to limit the width of the screen by having the navigation bar at the side, as the app must run in Landscape mode.
Here is the screenshots of what I have come up with instead of the SplitView;
http://i.stack.imgur.com/fdy21.png
The image is in a UIImageView,
And I have added a PopOver to the button that is linked to the UITableView.
What I want, is to be able to select an image from the PopOver Navigation, and it will change the image in the UIImageView to the corresponding.
Sorry if I haven't explained myself enough... I'm new to XCode!
Also: I am using XCode in Storyboard mode;
http://i.stack.imgur.com/RSuyY.png
Thanks,
Alex
To make the master view not be static on the side, implement this method in your UISplitViewControllerDelegate:
- (BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation
return YES from this method, and the split view controller will behave the same way in landscape as it does in portrait
I am developing PDF reader. I am facing problem while rotating the simulator. What I am doing is, when view is loaded by the ViewController(i.e. in the loadView), I am creating the UIScrollView which contains UIImageView and UIView of the same size(i.e. size of the PDF page). It is working perfectly in the portrait mode. But when I rotate the simulator in the landscape mode, the view is not autoresized according to device. I have tried
self.view.autoresizesSubviews = YES;
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
in the viewDidLoad() of the ViewController
But it's not working. I am confused how the above two properties work. I guess these properties will autoresize the UIScrollView to the size of root view in which I am loading UIScrollView. But what should be done to autoresize the main view in which UIScrollView is loaded??
I've experienced the same problem when trying to utilise the auto resizing methods. So, I hope this will help. (P.S. I'm assuming you're creating the UI programmatically and not via IB)
So have you tried this?
Inside your viewcontroller add the following:
// Set the View Controller to fit the whole screen.
-(BOOL)wantsFullScreenLayout{
return YES;
}
Inside the loadView method amend your scrollView to:
// set the initial size of your scrollView object.
[scrollView setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
// Set the auto resizing attributes.
[scrollView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
In addition to this you might need to set the autoresizingmask margins for either the UIView or UIImageView depending on the type of layout you require when the device is rotated.
This is late reply... It may help if you didn't Fix it yet.
When you create any app in portraid mode and if you want it to rotate (resize) to landscape mode, you should do it in User Interface Builder or .xib (or in Storyboard iPad or iPhone)file.
So to check or to check rotate in the Simulator:
Go to "USER INTERFACE BUILDER", or ".XIB" (or "Storyboard iPad or iPhone") file.
Then select "UIImageView" and go to "SHOW THE ATTRIBUES INSPECTOR".
In the fourth tab (Attributes Inspector) set the mode to “Aspect Fit”, and in the third tab (Size Inspector) and in the fifth tab (Size Inspector) set the autosizing attributes to the following:
Set the arrows to all directions. Sorry can't load image.
Do the same for "UIView" (3).
Before you move on, you can double check that you’ve gotten all of the autosizing attributes right by selecting the Detail View Controller, and changing the orientation from Portrait to Landscape: Sorry can't load image for now...
You can Check or Change to "Landscape or Portrait" on the top right side "Simulated Metrics" select under "Size" the "Orientation".
If something isn’t right, don't worry: Just change it back to Portrait and double check the settings.
I've been searching for some time for an answer on this problem:
How can I keep the scrollbars on my UIScrollView and UIWebview visible? So that the user knows he can scroll up or down. (like in firefox or any other browser so without touching the scrollvie first)
I read on some sites that it wasn't possible, so my other question would be:
Is there a way to add a "scrollbar" to a scrollview or webview?
Thank you very much
Maybe you could use this:
flashScrollIndicators
It won't show the scrollbar all the time, but it just flashes when the view is loaded.
Edited: Other solution:
In your view didload, you make a scrollview of you webview like this:
UIScrollview *scrollview = [webview.subviews objectAtindex:0];
you have to set the delegate of the scrollview on self:
scrollview.delegate= self
in your .h file you add
When you place in your .m file you can use:
-(void)ScrollviewDidscroll:...
(I don't know if it works when you have multiple scrollviews)
Yes you can try adding a custom view ( can be image view) on top the scrollbar. You will have to monitor the contentOffset and contentSize to know where you are. Based on this information, you can position your custom scroll bars.