我正在开发一个 e-pub 应用程序,并希望使用 UIScrollView 来显示多个页面。但我发现通过查看断点调用 viewDidLoad 后,scrollView 变量为空。编码:
#import <UIKit/UIKit.h>
@interface PagedScrollViewController : UIViewController <UIScrollViewDelegate>
@property (nonatomic, strong) IBOutlet UIScrollView *scrollView;
@property (nonatomic, strong) IBOutlet UIPageControl *pageControl;
@end
.m 文件:
@implementation PagedScrollViewController
@synthesize scrollView = _scrollView;
@synthesize pageControl = _pageControl;
@synthesize pageImages = _pageImages;
@synthesize pageViews = _pageViews;
- (void)viewDidLoad {
NSLog(@"paged view did load");
[super viewDidLoad];
self.title = @"Paged";
而且我发现在viewDidload之后scrollView仍然设置为null。在以前的视图中,我使用下面的代码切换到上面的视图:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
NSLog(@"touch pressed");
PagedScrollViewController *indexView = [[PagedScrollViewController alloc] init];
[self.navigationController pushViewController:indexView animated:YES];
NSLog(@"touch pressed 2");
}