2
我目前使用滑動手勢來切換視圖控制器,我想知道如果我可以在不使用uiscrollview的情況下在每個視圖控制器上實現uipagecontrol。使用UIPageControl沒有UIScrollView
這裏是如何我從一個視圖控制器到另一個:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.title = @"Home";
UIBarButtonItem *settingsButton = [[UIBarButtonItem alloc] initWithTitle:@"\u2699" style:UIBarButtonItemStyleBordered target:self action:@selector(settingsButtonPressed:)];
[settingsButton setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont boldSystemFontOfSize:24], UITextAttributeFont,nil] forState:UIControlStateNormal];
self.navigationItem.leftBarButtonItem = settingsButton;
UIBarButtonItem *systemAction = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(showMenu)];
self.navigationItem.rightBarButtonItem = systemAction;
UISwipeGestureRecognizer *swipeRecognizer = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeLeft:)];
swipeRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
[self.view addGestureRecognizer:swipeRecognizer];
}
- (IBAction)swipeLeft:(UIGestureRecognizer *)sender
{
HomeTwo *homeTwo = [[HomeTwo alloc]initWithNibName:@"HomeTwo" bundle:nil];
homeTwo.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self.navigationController pushViewController:homeTwo animated:YES];
}
你能讓我知道一些示例代碼的更多細節嗎? – Dinesh
@Dinesh,如果你有一個特定的問題,你應該創建一個新的問題,並顯示你的代碼。代碼基本上只是'currentPage'。 – Wain
我的問題與此主題相同。我想使用UIPageControl在不使用UIScrollView的情況下在視圖之間切換。我有2個子視圖控制器。我想知道如何加載視圖。 – Dinesh