.h
1 2 3 4 5 | @interface SecondViewController : UIViewController { IBOutlet UIWebView *stockTrend; IBOutlet UISegmentedControl *segmentControl; } - (IBAction)segmentControlAction:(id)sender; |
.m
1 2 3 4 5 6 7 8 9 10 11 | - (IBAction)segmentControlAction:(id)sender { NSInteger segment = segmentControl.selectedSegmentIndex; if (segment == 0) { [stockTrend loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"網址1"]]]; } else if (segment == 1) { [stockTrend loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"網址2]]]; } } |