开发者

Scrollview Obj C iPhone doesn't scroll - Still not working... any other suggestion?

I am new at iPhone and still trying to understand everything. I added the code below but still doesn't work. Is there something special using the emulator maybe to make it scroll?

I also attached the scrollview to the SV below. I tried moving the scrollview under the text view and above it,

The several text entries I have are all on the text view

 #import <UIKit/UIKit.h>


    @interface UserEdit : UIViewController {

    IBOutlet    UIScrollView *SV;



    }


@property(nonatomic, retain) IBOutlet UIScrollView *SV;

@end


//

#import "UserEdit.h"


@implementation UserEdit


- (void)viewDidLoad {
    [super viewDidLoad];



    SV.contentSize=CGSizeMake(320,950);





}

I have read several posts on the ScrollView but I am not able to make it work.

I did this in the interface builder:

I created a UIView and put a label on it. Ran the app and that worked great.

Then I resized the UIView so it was taller than the normal window.

I placed a scroll view at the top of the tall window and also placed several more labels throughout the scroll view.

I attached the scroll view as a delegate to the file开发者_JAVA技巧 owner.

Then I ran this in the simulator and I wasn't able to scroll.

Is there something with the emulator that I need to do to make it scroll or did I do something else wrong?


Make sure the contentSize of your scrollview is larger. refer this post for help.

Scrollview doesnt need to scroll if the contents it needs to display fits in its frame.


You will need to adjust the content size of the scrollview property to the taller view size.
e.g.

scrollView.contentSize=CGSizeMake(320,500);


You need to set the contentSize property of the scrollview. Set this value to the total height and width of the views contained in the scrollview. You set this property only via code and not in Interface Builder.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜