• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Accessing items in a UIScrollView?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Accessing items in a UIScrollView?


  • Subject: Accessing items in a UIScrollView?
  • From: "Eric E. Dolecki" <email@hidden>
  • Date: Fri, 30 Jul 2010 15:14:02 -0400

I am trying to quickly prototype something - I am stuffing a bunch of
subclassed UIButton controls into a UIScrollView. I would like to access
those items later from another method, but I don't know how to properly
access them without resorting to an NSArray approach.

I have this (setState is a method in the BasicListItem subclassed UIButton
class):

int yPos = 0;

    for(int i = 0; i<20; i++ ){

        BasicListItem *listItem = [[BasicListItem alloc]

                                   initWithFrame:CGRectMake(9,yPos,302,26)];

        listItem.tag = i;

        [listItem setTitleColor:[UIColor blackColor]
forState:UIControlStateNormal];

        [listItem setTitle:@" Music" forState:UIControlStateNormal];

        [listItem addTarget:self action:@selector(buttonClicked:)
forControlEvents:UIControlEventTouchUpInside];

        yPos += 44;

        [scrollView addSubview:listItem];

        //[itemView addSubview:listItem];

    }



    scrollView.contentSize = CGSizeMake(itemView.frame.size.width, yPos);

}


In another method I try to access all of those elements in the scrollview...
(which barfs)


 -(void) buttonClicked:(id)sender

{

    int tag = [sender tag];

    for(int i=0;i<20;i++){

        BasicListItem *tmp = (BasicListItem*)[scrollView viewWithTag:i];

        if( tag != i ){

            [tmp setState:NO]; //Barf here

        }

    }

    NSLog(@"%d",tag);

}


*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[UIScrollView setState:]: unrecognized selector sent to instance
0x593e820'


How can I dig into the scrollview and access those BasicListItem objects?
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Accessing items in a UIScrollView?
      • From: Fritz Anderson <email@hidden>
  • Prev by Date: Re: does anyone use IKImageView?
  • Next by Date: Re: Accessing items in a UIScrollView?
  • Previous by thread: Re: does anyone use IKImageView?
  • Next by thread: Re: Accessing items in a UIScrollView?
  • Index(es):
    • Date
    • Thread