7.2. Wykrywanie gestu obrotu

Problem

Chcesz wykryć, kiedy użytkownik próbuje obrócić element na ekranie, używając do tego palców.

Rozwiązanie

Utwórz egzemplarz klasy UIRotationGestureRecognizer i dołącz go do widoku docelowego.

- (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; self.helloWorldLabel = [[UILabel alloc] initWithFrame:CGRectZero]; self.helloWorldLabel.text = @"Witaj świecie!"; self.helloWorldLabel.font = [UIFont systemFontOfSize:16.0f]; [self.helloWorldLabel sizeToFit]; self.helloWorldLabel.center = self.view.center; [self.view addSubview:self.helloWorldLabel]; self.rotationGestureRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(handleRotations:)]; [self.view ...

Get iOS 5. Programowanie. Receptury now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.