신속하게 작성 하시겠습니까? 난 강력하게 스위프트와 오브젝티브 C 상호 운용성에 리소스를 참조하시기 바랍니다 - 나는 문제가 신속 내 첫 번째 언어이며이 모든목표 C에서 UIScroll 및 UIPageControl을 신속하게 변환
UIScrollView * scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * 3, scrollView.frame.size.height);
scrollView.delegate = self;
UIPageControl * pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, 90, scrollView.frame.size.width, 20)];
pageControl.numberOfPages = scrollView.contentSize.width/scrollView.frame.size.width;
[pageControl addTarget:self action:@selector(changePage:) forControlEvents:UIControlEventValueChanged];
Then you need to add the following two methods:
- (IBAction)changePage:(id)sender {
CGFloat x = pageControl.currentPage * scrollView.frame.size.width;
[scrollView setContentOffset:CGPointMake(x, 0) animated:YES];
}
-(void) scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
NSInteger pageNumber = roundf(scrollView.contentOffset.x/(scrollView.frame.size.width));
pageControl.currentPage = pageNumber;
얼마나 당신이 신속 이해한다는? 어느 부분에 고민하고 있습니까? – Okapi
글쎄, 필자는 PageController와 UIScrollView를 연결하고 싶지만, 필요한 리소스가 있지만 pageController 함수를 호출 할 때 오류가 발생한다는 것을 충분히 알고있다. 예를 들어, 나는 changePage (보낸 사람 : UIPageControl) {pageControl.currentPage - pageControl.currentPage를 사용할 수 없다는 오류가 있습니다} – Tom