Note that there are some explanatory texts on larger screens.

plurals
  1. POwhen UISegmentcontrol item changing, why it will hide customBadge in IOS 5?
    primarykey
    data
    text
    <p>I have added custom Badge on UISegmentControl. In <code>Xcode 4.0.2 SDK 4.3</code> its working fine. But in <code>Xcode 4.2 SDK 5.0</code> custom badge is not shown when another item is selected. I dont know why this happens? I'm using following code for <code>IOS 4.3 Xcode 4.0.2</code>:</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; super.tableView.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"wallpaper.png"]]; NSLog(@"Root View Loaded"); segmentedControl = [[UISegmentedControl alloc] initWithItems: [NSArray arrayWithObjects: @"Home",@"Surveys",@"Results",@"Create",@"Settings", nil]]; [segmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged]; segmentedControl.frame = CGRectMake(0, 0, 310, 40); segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar; segmentedControl.tintColor = [UIColor darkGrayColor]; segmentedControl.momentary = NO; segmentedControl.highlighted = YES; segmentedControl.selectedSegmentIndex = 0; UIBarButtonItem *segmentBarItem = [[UIBarButtonItem alloc] initWithCustomView:segmentedControl]; NSArray *segmentBarArray = [NSArray arrayWithObjects: segmentBarItem,nil]; [[self appDelegate] setSegmentedControl:segmentedControl]; [[self appDelegate] setSegmentBarArray:segmentBarArray]; [self setToolbarItems:[[self appDelegate] segmentBarArray] animated:NO]; [[self navigationController] setToolbarHidden:NO animated:YES]; [self.navigationItem setHidesBackButton:YES animated:YES]; self.navigationController.toolbar.tintColor = [UIColor blackColor]; int surveycount = [[self appDelegate] getUnreadSurveyCount]; surveyCountBadge = [CustomBadge customBadgeWithString:[NSString stringWithFormat:@"%d",surveycount]]; [surveyCountBadge setFrame:CGRectMake(105, -10, surveyCountBadge.frame.size.width, surveyCountBadge.frame.size.height)]; [segmentedControl addSubview:surveyCountBadge]; if (surveycount == 0) { [surveyCountBadge setHidden:YES]; }else{ [surveyCountBadge setHidden:NO]; } } -(void)segmentAction:(id) sender{ UISegmentedControl *segmentedControl = (UISegmentedControl *)sender; NSLog(@"selected index is %d",segmentedControl.selectedSegmentIndex); if (segmentedControl.selectedSegmentIndex == 0) { [self.navigationController popToRootViewControllerAnimated:YES]; } else if(segmentedControl.selectedSegmentIndex ==1){ surveyForMeViewController = [[SurveyForMeView alloc] initWithNibName:@"SurveyForMeView" bundle:nil]; [self.navigationController pushViewController:surveyForMeViewController animated:YES]; } else if(segmentedControl.selectedSegmentIndex ==2){ resultViewController = [[ResultView alloc] initWithNibName:@"ResultView" bundle:nil]; [self.navigationController pushViewController:resultViewController animated:YES]; } else if (segmentedControl.selectedSegmentIndex ==3) { newSurveyViewController = [[NewSurveyView alloc] initWithNibName:@"NewSurveyView" bundle:nil]; [self.navigationController pushViewController:newSurveyViewController animated:YES]; } else if (segmentedControl.selectedSegmentIndex ==4) { settingsViewControlle = [[SettingsView alloc] initWithNibName:@"SettingsView" bundle:nil]; [self.navigationController pushViewController:settingsViewControlle animated:YES]; } } </code></pre> <p>Any thing else should I mention in this?</p>
    singulars
    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.
 

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