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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to