Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIScrollView does not scroll when an object is inside

I made a UIScrollView inside a UIViewController I have like 5 ViewControllers my problem is in the 4th one.

The UIScrollView I made does scroll when I put notting it it (so no label no button, no objects at all) but when I put even a label (or anything) in the UIScrollView it stops working.

Edit:

I have try'd making the same thing in a new project, for some reason it does work I think it has something to do with the fact that it is in the 4th ViewController and the new one I made, was made, in the First automatically made viewcontroller. I do not yet have a answer please help.

My code: viewcontroller.h

#import <UIKit/UIKit.h>

@interface viewcontroller : UIViewController
@property (weak, nonatomic) IBOutlet UIScrollView *ScrollerMdon;

@end

viewcontroller.m

@synthesize ScrollerMdon;

- (id)initWithNibName:(NSString *) nibNameOrNil bundle:(NSBundle *) nibBundleOrNil
{
    self = [super initWithNibName: nibNameOrNil bundle:nibBundleOrNil];
    if(self)
    {

    }
return self;
}

-(void)viewDidLoad
{
[ScrollerMdon setScrollEnabled:YES];
[ScrollerMdon setContentSize:CGSizeMake(320,1000)];
[super viewDidLoad];
}

@end

In xcode viewcontroller connection inspector my outlet ScrollerMdon is connected with *Scroll View(*which I inserted in my viewcontroller)

In xcode UIScrollView connection inspector my Referencing outlet ScrollerMdon is connected with viewcontroller.

Please help me I have been trying to solve this for 5 hours.. I can't stand it anymore.

Edit:

I try to make it possible for a single viewcontroller to hold like 17 textboxes I see no other way than doing it with a UIScrollView if there are any suggestions I would be really happy.

Edit2:

I have try'd to make it all aggain putting the same class on a different view controller and the other way around, I kinda rewrote the code and everything it's exactly the same as what I made in the other project but it does not work.(when an object is inside..)

2 foto's of my program. Srry for the small and bad images, for some reason they moved without my permision but it is enough information I guess.(I use VMWare 8 with os x leopard on it)

foto 1

foto 2

Me Scrolling without items: imgur.com/cd16I

Me desperately Scrolling with items: imgur.com/hNUl1

Since I can only post 2 hyperlinks you have to open these yourself. PS. please upvote this if you do not know the answer for I need a answer and there will probably be more viewers if it gets upvoted, ty.

Edit3:

I am now copying my entire code and build of the app in a different project hope this wil work :S.

like image 231
Senior Me Avatar asked Mar 16 '26 01:03

Senior Me


2 Answers

I had the SAME exact problem that I ran into yesterday. Drove me nuts for hours... This was a brand new project that I just started like a week or so ago.

The thing is, I had another project that had the exact same setup essentially that I had started last summer that has no problems. Tabbed application, VC that has a UIScrollView with many uiviews, labels, images etc... works great.

So what changed from that project to this project? The version of Xcode that I started the project out in. The project from last summer did NOT have the AutoLayout enabled as an option. This new one did ( Xcode 4.6 ).

If I turn off "Use AutoLayout" for the entire project it works fantastic.

In the Utilities panel, click on the File Inspector tab. In the section for "Interface Builder Document" you'll see a checkbox for "Use AutoLayout". De-select that and re-build your app. Just found this trick not more than 10 minutes ago for my own project -- works great.

Hope this works for your project... good luck!

enter image description here

like image 150
Drew Avatar answered Mar 17 '26 13:03

Drew


I found the solution it might not be the perfect solution but it works.

The problem seemed to be somewhere in my first project since I could make it work in other projects, so I copy'd my entire project to a different project and this way it worked.

like image 44
Senior Me Avatar answered Mar 17 '26 14:03

Senior Me



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!