D9E54D23BA8324DF80FEB0E08F4F2D  

.h

 

@interface ViewController : UIViewController
{
//IBOutlet UIImageView* teamContentView;
IBOutlet UIImageView *imageView;

 

IBOutlet UIScrollView* scrolContent;
}
@property (nonatomic, retain)UIScrollView *scrolContent;
@end




.m

 

@implementation ViewController

 

@synthesize scrolContent;

 

- (void)viewDidLoad
{
[super viewDidLoad];

 

UIImage *image = [UIImage imageNamed: @"content.png"];
UIImageView *imageViewScroll = [[UIImageView alloc] initWithImage:image];



[scrolContent addSubview:imageViewScroll];
[scrolContent setScrollEnabled:YES];
[scrolContent setContentSize:CGSizeMake(250, 700)];
}




793B297B6BDFB5F670AD3F57F7691B  

注意 UICrollView不需超過螢幕大小 靠的是ContentSize 另一種純靠程式方法

 

.h
@interface ViewController : UIViewController
{
UIView *headerView;
}

 

@property (nonatomic, retain) UIView *headerView;



- (void) initHeaderView;

 

@end



.m
@synthesize headerView;



- (void)viewDidLoad
{
[super viewDidLoad];

 

[self initHeaderView];
[self.view addSubview:headerView];



}
- (void) initHeaderView
{
UIView *header = [[UIView alloc] initWithFrame: CGRectMake(0, 0, 320, 350)];

 

UIScrollView *scroll = [[UIScrollView alloc] initWithFrame: CGRectMake(43, 22, 250, 328)];
scroll.contentSize = CGSizeMake(250, 700);

 

UIImage *image = [UIImage imageNamed: @"about_content.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage: image];
imageView.userInteractionEnabled = YES;



[scroll addSubview: imageView];

 

//[self.view addSubview: scroll]; //without UIView header

 

[header addSubview: scroll];



self.headerView = header;



}
arrow
arrow
    全站熱搜

    戮克 發表在 痞客邦 留言(0) 人氣()