#import "XViewController.h" @interface XViewController () @end @implementation XViewController - (void)viewDidLoad { self.flowerDetailView.hidden=YES; [self getFlower:nil]; [super viewDidLoad]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (IBAction)toggleFlowerDetail:(id)sender { self.flowerDetailView.hidden=![sender isOn]; } - (IBAction)getFlower:(id)sender { NSURL *imageURL; NSURL *detailURL; NSString *imageURLString; NSString *detailURLString; NSString *color; int sessionID; color=[self.colorChoice titleForSegmentAtIndex: self.colorChoice.selectedSegmentIndex]; sessionID=random()%50000; imageURLString=[[NSString alloc] initWithFormat: @"http://www.floraphotographs.com/showrandomios.php?color=%@&session=%d" ,color,sessionID]; detailURLString=[[NSString alloc] initWithFormat: @"http://www.floraphotographs.com/detailios.php?sessiono=%d" ,sessionID]; imageURL=[[NSURL alloc] initWithString:imageURLString]; detailURL=[[NSURL alloc] initWithString:detailURLString]; [self.flowerView loadRequest:[NSURLRequest requestWithURL:imageURL]]; [self.flowerDetailView loadRequest:[NSURLRequest requestWithURL:detailURL]]; self.flowerDetailView.backgroundColor=[UIColor clearColor]; } @end
效果:
需要的输出口包括3项:
用于指定颜色打分段控件UISegmentedControl:colorChoice
用于显示