0

我有一个用故事板构建的表格应用程序,所以我想为表格中的项目添加分页可能性。我使用了本教程

所以我将新视图添加到情节提要和视图上的 UIScrollView。比做了一个属性 UIScrollView* scrollView; 并在情节提要中制作关系 scrollView - ECOMClPanelPagingViewController。(ECOMClPanelPagingViewController 是我的视图的 UIViewController 类。

。H

#import <UIKit/UIKit.h>
@interface ECOMClPanelPagingViewController : UIViewController
{
    UIScrollView *scrollView;
}
@property (nonatomic, retain) IBOutlet UIScrollView* scrollView;
@end

.m

#import "ECOMClPanelPagingViewController.h"
@interface ECOMClPanelPagingViewController ()
@end
@implementation ECOMClPanelPagingViewController
@synthesize scrollView;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
    }
    return self;
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    NSArray *colors = [NSArray arrayWithObjects:[UIColor redColor], [UIColor greenColor], [UIColor blueColor], nil];
    for (int i = 0; i < colors.count; i++) {
        CGRect frame;
        frame.origin.x = self.scrollView.frame.size.width * i;
        frame.origin.y = 0;
        frame.size = self.scrollView.frame.size;
        UIView *subview = [[UIView alloc] initWithFrame:frame];
        subview.backgroundColor = [colors objectAtIndex:i];
        [self.scrollView addSubview:subview];
        [subview release];
    }
    self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * colors.count, self.scrollView.frame.size.height);
}
- (void)viewDidUnload
{
    self.scrollView = nil;
}
- (void)dealloc
{
    [scrollView release];
    [super dealloc];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}
@end

所以我只看到带有导航控制器的白色背景..谁能帮助我?

4

1 回答 1

1

只需取消选中 Use Autolayout 选项

于 2013-04-04T09:50:03.057 回答