Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone



Clound SSD Virtual Server

iOS/iPhone Rotation Gesture Recognizer (UIRotationGestureRecognizer)

iOS/iPhone Rotation Gesture Recognizer (UIRotationGestureRecognizer) สำหรับ Rotation Gesture เป็น Gesture บน iOS ในรูปแบบของการใช้ นิ้วตั้งแต่ 2 นิ้วขึ้นไป ทำการหมุ่ม (Rotate) รายการ View หรือ Object ต่าง ๆ บนหน้าจอ Application โดย Rotation Gesture จะใช้ Class ของ UIRotationGestureRecognizer ในการที่จะ Detect Gesture ที่เกิดขึ้น

iOS/iPhone Rotation Gesture Recognizer (UIRotationGestureRecognizer)

iOS/iPhone Rotation Gesture Recognizer (UIRotationGestureRecognizer)


Rotation Gesture Recognizer (UIRotationGestureRecognizer) อาจจะไม่ค่อยได้พบเจอได้ง่ายนักใน Application ทั่ว ๆ ไป เพราะส่วนมากอาจจะได้ใช้กับ Application ที่เกี่ยวข้องกับ Graphic ซะมากกว่า แต่การใช้งานก็ไม่ได้ยากอะไรมากมาย

การหมุน Rotation Gesture บน iOS Simulator
สามารถใช้การกดปุ่ม Option บน Keyboard แล้วคลิกแล้วหมุ่นเมาส์บนหน้า Simulator


Rotation Gesture Recognizer (UIRotationGestureRecognizer)
- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    
    // Rotation Gesture
    UIRotationGestureRecognizer *rotationGesture =[[UIRotationGestureRecognizer alloc]
                                                   initWithTarget: self
                                                   action: @selector(rotationGuestureHandle:)];
    [[self view] addGestureRecognizer:rotationGesture];
}

-(void) rotationGuestureHandle:(UIRotationGestureRecognizer *) sender {
    
    NSLog(@"Rotation Gesture Handling");
    
}


Example การใช้ Rotation Gesture (UIRotationGestureRecognizer) ในการหมุ่นรูปภาพ Image View (UIImageView)

iOS/iPhone Rotation Gesture Recognizer (UIRotationGestureRecognizer)

เริ่มต้นด้วยการสร้าง Project บน Xcode แบบง่าย ๆ ด้วย Single View Application








iOS/iPhone Rotation Gesture Recognizer (UIRotationGestureRecognizer)

เลือกและไม่เลือกรายการดังรูป

iOS/iPhone Rotation Gesture Recognizer (UIRotationGestureRecognizer)

ตอนนี้หน้าจอ View จะยังว่าง ๆ

iOS/iPhone Rotation Gesture Recognizer (UIRotationGestureRecognizer)

ทำการ Add ไฟล์รูปภาพเข้ามาใน Project

iOS/iPhone Rotation Gesture Recognizer (UIRotationGestureRecognizer)

ทำการลาก Object ที่มีชื่อว่า Image View (UIImageView) เข้าในหน้าจอ Design ของ View

iOS/iPhone Rotation Gesture Recognizer (UIRotationGestureRecognizer)

เลือกรูปภาพเพื่อแสดงบน Image View

iOS/iPhone Rotation Gesture Recognizer (UIRotationGestureRecognizer)

ใน Class ของ .h ให้เชื่อม IBOutlet ให้กับ Image View

Code ทั้งหมดของ .h และ .m ในภาษา Objective-C

ViewController.h
//
//  ViewController.h
//  rotationGesture
//
//  Created by Weerachai on 11/17/55 BE.
//  Copyright (c) 2555 Weerachai. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
{
    IBOutlet UIImageView *imgView;
}

@end


ViewController.m
//
//  ViewController.m
//  rotationGesture
//
//  Created by Weerachai on 11/17/55 BE.
//  Copyright (c) 2555 Weerachai. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    
    // Rotation Gesture
    UIRotationGestureRecognizer *rotationGesture =[[UIRotationGestureRecognizer alloc]
                                                   initWithTarget: self
                                                   action: @selector(rotationGuestureHandle:)];
    [[self view] addGestureRecognizer:rotationGesture];
}

-(void) rotationGuestureHandle:(UIRotationGestureRecognizer *) sender {
    
    NSLog(@"Rotation Gesture Handling");
    
    UIRotationGestureRecognizer *rotation = (UIRotationGestureRecognizer *)sender;
    
    CGFloat angle = rotation.rotation;
    imgView.transform = CGAffineTransformRotate(imgView.transform, angle);
    rotation.rotation=0.0;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)dealloc {
    [imgView release];
    [super dealloc];
}
@end









Screenshot

iOS/iPhone Rotation Gesture Recognizer (UIRotationGestureRecognizer)

แสดงการปุ่ม Rotation Gesture ของรูปภาพ

iOS/iPhone Rotation Gesture Recognizer (UIRotationGestureRecognizer)

แสดงการปุ่ม Rotation Gesture ของรูปภาพ

iOS/iPhone Rotation Gesture Recognizer (UIRotationGestureRecognizer)

แสดงการปุ่ม Rotation Gesture ของรูปภาพ

   
Share


ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท


ลองใช้ค้นหาข้อมูล


   


Bookmark.   
       
  By : ThaiCreate.Com Team (บทความเป็นลิขสิทธิ์ของเว็บไทยครีเอทห้ามนำเผยแพร่ ณ เว็บไซต์อื่น ๆ)
  Score Rating :  
  Create/Update Date : 2012-11-20 10:02:53 / 2017-03-26 09:53:12
  Download : Download  iOS/iPhone Rotation Gesture Recognizer (UIRotationGestureRecognizer)
 Sponsored Links / Related

 
iOS/iPhone Swipe Gesture and Storyboard , View (Objective-C, iPhone, iPad)
Rating :

 
iOS/iPhone Gesture Recognizer (UIGestureRecognizer) - (Objective-C , iPhone)
Rating :

 
iOS/iPhone Swipe Gesture Recognizer (UISwipeGestureRecognizer) Swipe Left / Right / Up / Down
Rating :

 
iOS/iPhone Pan Gesture Recognizer (UIPanGestureRecognizer) Panning or dragging
Rating :

 
iOS/iPhone Pinch Gesture Recognizer (UIPinchGestureRecognizer) Pinching in and out (for zooming a view)
Rating :

 
iOS/iPhone Gesture and Image View Slide Show - (Objective-C , iPhone)
Rating :

 
iOS/iPhone Tap Gesture Recognizer (UITapGestureRecognizer) Tap and Double Tap
Rating :

 
iOS/iPhone Long Press Gesture Recognizer (UILongPressGestureRecognizer)
Rating :


ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่