私はuiview application.iを取ったコントローラのview.my要件に画像を置いた画像はマウスの助けを借りて移動可能でなければなりません。マウスをドラッグすると移動する必要があります。画像の移動は、ビューの特定の部分のみに制限する必要があります。 は、誰かが私は、マウス(カーソル)はiPhoneやiPadには存在しないことを伝えることは非常に残念ですdinakar画像は特定の領域でマウスを使用して移動する必要があります
2
A
答えて
2
これは、touchesBeganイベントとtouchesMovedイベントで実行できます。
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
// This gets you starting position of
UITouch *touch = [ [ event allTouches ] anyObject ] ;
float touchXBeginPoint = [ touch locationInView:touch.view ].x ;
float touchYBeginPoint = [ touch locationInView:touch.view ].y ;
// Calculate the offset between the current image center and the touched points.
// Moving image only along X - direction and try thinking as how to move in
// any direction using this as a reference. It isn't that hard.
touchOffset = image.center.x - touchXBeginPoint ;
// touchOffset should be a member variable of class or a variable with global scope
}
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
// Calculate the difference from previous position and the current position
// Add this difference to the previous point and move the image center to that point.
// How ever, you should have an UIImageView outlet connected on to the image placed
// on the interface builder.
// And regarding image movement restriction, since you always have co-ordinates with
// you, you can set the boundaries.
UITouch *touch = [ [ event allTouches ] anyObject ] ;
float distanceMoved =([ touch locationInView:touch.view ].x + touchOffset) - image.center.x ;
float newX = image.center.x + distanceMoved ;
if(newX > 30 && newX < 290) // setting the boundaries
image.center = CGPointMake(newX, image.center.y) ;
}
希望します。
3
3
ロビンは、これらのは、あなたがこのlink images.see移動するためのチュートリアルを読む必要があり、別のイベント
ではありませんので、ちょうどシミュレータ用のタッチとして使用right.mouseカーソルです。
これはあなたに役立つでしょう。
関連する問題
- 1. jqueryセレクタは、領域内にある要素のない領域を選択する必要があります
- 2. スパークスクロールバーの領域を保存する必要があります
- 3. 特定の領域を選択して画像を切り抜く方法
- 4. 画像から矩形領域を切り抜く画像を使用して
- 5. 画像をマージするときに画像を上に移動する必要があります
- 6. ビュー要素を特定するim特定の領域(iphone)
- 7. 移動コンストラクタはnoexceptである必要がありますか?
- 8. ホバリングヒット領域が移動する
- 9. スイングでキャンバス上の画像の特定の領域を拡大する方法
- 10. スタック領域としてメモリ領域を使用しますか?
- 11. CSS - 画像の周りにテキストが流れるようにテキストを移動する必要があります
- 12. ツールを使用して、画像内の特定の領域の色コードを取得したり、 をペイントする方法画像
- 13. divにFacelet領域をラップする必要がありますか?
- 14. マウス移動イベントで画像を回転
- 15. touchesmoved + drawrect関数を使用して特定の領域から別の特定の領域に線を描画する方法
- 16. javascriptを使用してフラッシュ内のビデオ領域を特定します
- 17. OpenCV:画像の特定の領域の各ピクセルを反復する方法
- 18. 画像のマッピング領域
- 19. invalidate(l、t、r、b)の後でクリップ領域を明示的に設定する必要がありますか?
- 20. jQueryのタブが移動する必要があります
- 21. Farseerを使用して特定の領域のオブジェクトをスローする
- 22. DisplayObjectの特定の領域にフィルタを適用しますか?
- 23. 矩形を使用して画像に検索領域を作成する
- 24. ベクトル要素は移動可能である必要がありますか?
- 25. GhostScriptを使用したPDFへの画像。画像ファイルを作成する必要はありません
- 26. CGPointが画像領域内にあるかどうかを確認します
- 27. 描画領域に画像を描画
- 28. CCSpriteの特定の領域にCCLiquid効果がありますか?
- 29. Flex GestureZoomが正しく動作しない特定の領域
- 30. capybara(ルビー)で特定の座標をクリック、ホールド、移動する必要があります
hii mahesh tnxのanswer.theアプローチは、このコードで試したものと同じです:[scale setFrame:CGRectMake(touchXBeginPoint +(touchLocation-touchXBeginPoint)、touchYBeginPoint +(touchLocation-touchYBeginPoint)、scaleFrame.size.width、scaleFrame。 size.height)];スケールは私が取得したimageView.theエラーです。 'touchXBeginPoint' undeclared.can uplsはthis.ifを見て、私のコードを理解できませんでした。plzは私のtask.iに応じてサンプルコードを与えてくれました。あなたが私を助けることを望みます。 – Dinakar
'エラーは 'touchXBeginPoint' undeclared'です - エラーメッセージははるかに明確です。どのように、新しいコードを投稿しました。 Ishuのリンクを参照してください。 – Mahesh