XCode 4.5 UiScrollView问题

the*_*men 3 xcode objective-c ios5

我正在尝试使用带有图像数组的页面控件来实现UIScrollView.我使用了另一个项目的相同代码,但它不适用于Xcode 4.5.调试时ScrollView框架属性全为0,但是scrollview Outlet连接良好.滚动中不显示图像.真的很奇怪.我观察到属性不像以前的版本那样自动合成.这是代码:

@interface dashboardViewController : UIViewController <UIScrollViewDelegate>{

    BOOL pageControlBeingUsed;

}

@property (strong, nonatomic) IBOutlet UIScrollView *scrollView;
@property (strong, nonatomic) IBOutlet UIPageControl *pageControl;

- (IBAction)changePage;

@end




   - (void)viewDidLoad
    {
        [super viewDidLoad];

        self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"fondo.jpg"]]];

        pageControlBeingUsed=NO;

        scrollView.delegate=self;

        [self buildScrollView];



        // Do any additional setup after loading the view.
    }

    -(void)buildScrollView{

        NSArray *imagesQueue = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"icoblog.png"], [UIImage imageNamed:@"icogaleria.png"], [UIImage imageNamed:@"icobio.png"], nil];

        for(int i = 0; i < imagesQueue.count; ++i) {

            UIImageView *image = [[UIImageView alloc] initWithImage:[imagesQueue objectAtIndex:i]];

            CGFloat xOrigin = i * (scrollView.frame.size.width);

            image.frame = CGRectMake(xOrigin, 0, scrollView.frame.size.width, scrollView.frame.size.height);

            [scrollView addSubview:image];

            image=nil;


        }

        scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * imagesQueue.count, self.scrollView.frame.size.height);



}
Run Code Online (Sandbox Code Playgroud)

非常感谢您的帮助.

Ste*_*han 8

在故事板中选择您的滚动视图,并取消选中文件属性下的"自动布局"