Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>UILabel is not interactive component Girish. So you cannot get the event of its selection. Better use UIButtons. I have edited your code and added one method. Just make the languageArray global and the code whould work fine.</p> <pre><code>-(void)youMethod { //int y=0; //NSMutableArray *languageArray=[[NSMutableArray alloc]initWithObjects:@"Chinese",@"Spanish",@"English",@"Arabic",@"Hindi",@"Bengali",@"Portuguese",@"Russian",@"Japanese",@"German",nil]; //UILabel *languageLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, y ,90,30 )]; languagValue=0; int y=0; NSMutableArray *languageArray=[[NSMutableArray alloc]initWithObjects:@"Chinese",@"Spanish",@"English",@"Arabic",@"Hindi",@"Bengali",@"Portuguese",@"Russian",@"Japanese",@"German",nil]; for(languagValue=0;languagValue&lt;[languageArray count];languagValue++) { UILabel *languageLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, y ,90,30 )]; UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom]; btn.frame = CGRectMake(0, y ,90,30 ); btn.tag = languagValue; [btn addTarget:self action:@selector(languageSelected:) forControlEvents:UIControlEventTouchUpInside]; NSLog(@"array count is @%d",[languageArray count]); languageLabel.text=[languageArray objectAtIndex:languagValue]; NSLog(@"array objectat index is @%@",[languageArray objectAtIndex:languagValue]); languageLabel.font=[UIFont systemFontOfSize:19.0]; languageLabel.backgroundColor=[UIColor clearColor]; [languageScrollView addSubview:languageLabel]; [languageScrollView addSubview:btn]; // [languageScrollView addSubview:languageLabel]; //y+=90; y+=languageLabel.frame.size.height; [languageLabel release]; } [languageScrollView setShowsHorizontalScrollIndicator:NO]; [languageScrollView setShowsVerticalScrollIndicator:NO]; [languageScrollView setContentSize:CGSizeMake(genderScrollView.frame.size.width, y)]; } -(void)languageSelected:(id)sender { UIButton * btn = (UIButton*)sender; int selectedIndex = btn.tag; NSString * selectedLanguage = [languageArray objectAtIndex:selectedIndex]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload