title: IOS get position
body: <p>I have a lot of button inside a UIScrollView and i am trying to get their position on button click. Here is my code:</p>
  
  <pre><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];
  </code></pre>
  
  <p>and </p>
  
  <pre><code>-(void) buttonClick:(UIButton*)button{
  if ([button tag]==1)
  {
       NSLog(@"position:%d",buton1.frame.origin.x);
  }
  else
  {
      NSLog(@"position:%d",buton2.frame.origin.y);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>What is wrong with my code.Thanks.</p>
  
  <p>I also tried with :</p>
  
  <pre><code>-(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);
  }
  </code></pre>
  
  <p>But i just get the same.Position 0;</p>