TextViews我努力學習UIPageViewController
S和打擊,我解決不了的問題。 這就是我試圖做的:ViewControllers在UIPageViewController
- 步驟:
- 我只是創造了2個視圖控制器和 故事板頁面視圖控制器。
- 然後,我向文件所有者
PageViewController
添加了一些代碼至 表現爲自身的dataSource
和delegate
。 - 當我跑步時,事情運作良好。
- 我在第二個視圖控制器中添加了一些按鈕和文本字段。
- 我跑了,效果很好。
- 現在我添加了一個文本視圖到第二個視圖控制器並運行。當我試圖在文本視圖內寫入內容時,頁面控件抖動並移動到第一個視圖控制器。
有沒有人有過這樣的經歷?
@interface AMPageViewController : UIPageViewController <UIPageViewControllerDataSource, UIPageViewControllerDelegate>
@end
實施:
#import "AMPageViewController.h"
@interface AMPageViewController()
{
UIViewController *mainController;
UIViewController* socController;
}
@end
@implementation AMPageViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard"
bundle: nil];
mainController = (UIViewController*)[mainStoryboard instantiateViewControllerWithIdentifier: @"First"];
socController = (UIViewController*)[mainStoryboard instantiateViewControllerWithIdentifier: @"Second"];
[self setViewControllers:@[mainController]
direction:UIPageViewControllerNavigationDirectionForward
animated:NO
completion:nil];
self.dataSource = self;
self.delegate = self;
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController
{
if (viewController == socController)
return mainController;
else return nil;
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController
{
if (viewController == mainController)
return socController;
else return nil;
}
- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController
{
return 2;
}
- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController
{
return 0;
}
@end
If you want to download and try the project
頁面視圖控制器的延遲讓您無論是滑動或輕敲接近一個邊緣翻開新的一頁。我猜你正在擊中左側的那個輕擊手勢識別器。 – rdelmar 2013-02-21 03:58:24
我不這麼認爲。請看附件項目https://dl.dropbox.com/u/62559842/PageViewcontrollerTest.zip – Bavan 2013-02-21 04:19:15
是的,我明白你的意思了。它與使用滾動轉換有關。如果將其更改爲捲曲,則表現正常。 – rdelmar 2013-02-21 04:47:53