2013-04-04 55 views
0

我有一個使用故事板構建的表格應用程序,所以我想爲表中的項目添加分頁可能性。我用this tutorial無法附加故事板中的UIScrollView分頁iOS

所以我添加了新視圖到故事板和視圖上的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 

所以我只能看到白色的背景,導航控制器..誰能幫我一下吧?

回答

1

只需要取消選中Use Autolayout選項