Also from Mitch, Bennett, Lees textbooks, I compiled the environment for Xcode 7
New iOS Project, Singleview application.
In the Xcode environment-UI layouts, adding UI objects, linking UI components, and UI objects.
UI layout: By dragging the UI component in the lower right corner into the blank layout in Main.storyboard
To add a UI object
In this example, the object of each UI component of the Iboutlet class is added to the instance variable of Viewcontroller-corresponds to three dynamic labels, a slider
A method for defining button actions is also defined outside the class
After you have defined it, right-click the corresponding label and pull the reference outlets one line out of the corresponding label object:
The dynamic labels, sliders, and buttons that will be connected in turn are connected.
Then add the action to the VIEWCONTROLLER.M Viewdidload method, adding the implementation for the action of the button and slider:
////VIEWCONTROLLER.M//radiostation////Created by Wang Yinhhao on 2/25/16.//copyright©2016 UTT Wangsta. All rights reserved.//#import "ViewController.h"#import "RadioStation.h"@interfaceViewcontroller ()@end@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; //additional setup after loading the view, typically from a nib.mystation= [[Radiostation alloc] Initwithname:@"STAR 94"Atfrequency:88.3];}- (void) didreceivememorywarning {[Super didreceivememorywarning]; //Dispose of any resources the can be recreated.}-(Ibaction) Sliderdidchange: (IDSender {[mystation setFrequency:setFrequency.value];}-(Ibaction) ButtonClick: (IDSender {[StationName settext:[mystation getName]]; [Stationfrequency settext:[nsstring stringWithFormat:@"%.1f", [Mystation getfrequency]]; if([mystation getfrequency] >= [radiostation minfmfrequency] &&[mystation getfrequency]<=[radiostation maxfmfrequency]) {[Stationband setText:@"FM"]; } Else if([mystation getfrequency] >= [radiostation minamfrequency] &&[mystation getfrequency]<=[radiostation maxamfrequency]) {[Stationband setText:@"AM"]; } Else{[Stationband setText:@"Invalid band!"]; }}@end
First iOS App radiostation