2

iOS アプリ内で画像を移動する必要がありますが、いくつかの問題が発生しています。画像を計算された座標に正しく移動できますが、正しい位置に表示される前に、移動を開始するボタンを2回クリックする必要があります。最初のクリックでは、画像は最初の位置にのみ表示されます。新しい位置に移動します。

これは私のコードです:

(編集済み)

Viewcontroller.m

#import "ndpViewController.h"

@interface ndpViewController ()

@end

@implementation ndpViewController
@synthesize image;

-(void)viewDidLoad
{

}

-(void)dealloc
{
}

- (IBAction)calculatePush:(id)sender {
    image.hidden=NO;
    image.center=CGPointMake(376, 927);
}
- (void)viewDidUnload {
}
@end

Viewcontroller.h

#import <UIKit/UIKit.h>
@interface ndpViewController : UIViewController
{
IBOutlet UIImageView *image;
}
@property (weak, nonatomic) IBOutlet UIButton *calculate;
@property (nonatomic,retain) UIImageView *image;
@end

画像が再配置される前に 2 回クリックする必要がある理由は何ですか? グラフィックの上の特定のポイントに表示される小さな画像 (クロスを表す) だけで、どんな種類のアニメーションも必要ありません。

どうもありがとうございました。

4

3 に答える 3

0

You have not posted enough code to know for sure. But let me try it this way. What happens if zfw <= 26308 ?? It appears nothing. So in that case nothing moves. How does it EVER move when zfw is <= 26308?

NOTE: Ok... the code as you have NOW posted it will NEVER relocate because you are always setting the position of the image to the same position on every click.

于 2012-10-07T12:27:27.113 に答える
0

一部のコードが正確に理解できません。しかし、「最初のクリックで何かを実行し、2 回目のクリックで別の操作を実行するにはどうすればよいですか?」という質問は理解できたと思います。

bool isFirstClick = true;

-(IBAction)CLickEvent:(id)sender{
    if(isFirstClick){
        //enter first click action here
        isFirstClick = false;
    }else{
        //enter second click action here
        isFirstClick = true;
    }   
} 
于 2012-10-07T13:02:36.247 に答える
0

実際、問題は私が思っていたよりもさらに奇妙です。アプリ内のテキスト ボックスにテキストを入力すると、最初のクリックで画像が移動しますが、それらのテキスト ボックスのいずれかに数字を入力すると、2 回目のクリックでしか移動しません。

なにか提案を????

于 2012-10-07T15:47:44.637 に答える