IOS obtenir la position

J'ai beaucoup de bouton à l'intérieur d'un UIScrollView et je suis en train d'essayer d'obtenir leur position sur clic du bouton. Voici mon code:

UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(2, 0, 262, 748)];
scrollView.contentSize=CGSizeMake(262, 816);
scrollView.bounces=NO;
scrollView.delaysContentTouches=YES;

buton1 = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
buton1.frame = CGRectMake(2, 0, 262, 102);
buton1.bounds = CGRectMake(2, 0, 262.0, 102.0);
[buton1 setTag:1];
[buton1 setImage:[UIImage imageNamed:@"left_gride.png"] forState:UIControlStateNormal];
[buton1 addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
     [scrollView addSubview:buton1];

et

-(void) buttonClick:(UIButton*)button{
if ([button tag]==1)
{
     NSLog(@"position:%d",buton1.frame.origin.x);
}
else
{
    NSLog(@"position:%d",buton2.frame.origin.y);
}

}

Quel est le problème avec mon code.Merci.

J'ai aussi essayé avec :

-(void) buttonClick:(UIButton*)button{
if ([button tag]==1)
{
     NSLog(@"position:%d",buton1.frame.origin.x);
}
else
{
    NSLog(@"position:%d",buton2.frame.origin.y);
}

-(void) buttonClick:(UIButton*)button{
if ([button tag]==1)
{
     NSLog(@"position:%d",button.frame.origin.x);
}
else
{
    NSLog(@"position:%d",button2.frame.origin.y);
}

Mais je viens d'obtenir le même.La Position 0;

Écrivez ce qui vous attend et de ce qui s'est passé, si vous exécutez ce code.
Je m'attendais à un retour de la position et de tout ce que j'obtiens est en position 0.

OriginalL'auteur flaviusilaghi | 2011-03-25