Word: Segmented the split Index pointers, indicators Current now the
Code creation
nsarray *itemname = [ nsarray arraywithobjects Span style= "FONT-FAMILY:MENLO;" >: @ " chicken wings " Span style= "Font-family:menlo;color: #D12F1B;" >@ " ribs " , nil Span style= "FONT-FAMILY:MENLO;" >];
uisegmentedcontrol *SEGSC = [[uisegmentedcontrol alloc] initwithitems: ItemName] ;
Segsc.segmentedcontrolstyle =uisegmentedcontrolsegmentcenter;
[SEGSC addTarget: self Action:@selector(segmentaction:) forcontrolevents:uicontroleventvaluechanged];
SEGSC. frame=cgrectmake(0, Max, +) ;
[Self. View addsubview: SEGSC];
Add a Click event
-(void) Segmentaction: (ID) Sender
{
Switch ([Sender Selectedsegmentindex]) {
Case 0:
{
Uialertview*alter = [[Uialertview Alloc] Initwithtitle:@"Tips" message:@"you clicked on chicken wings." Delegate: Self Cancelbuttontitle:@"Determine" Otherbuttontitles:Nil, Nil];
[Alter show];
}
break;
Case 1:
{
Uialertview*alter = [[Uialertview Alloc] Initwithtitle:@"Tips" message:@"you clicked on the ribs" Delegate: Self Cancelbuttontitle:@"Determine" Otherbuttontitles:Nil, Nil];
[Alter show];
}
break;
default:
break;
}
}
Drag and drop to create
1 Create and set properties
dragging Uisegmentedcontrol to the Main.storyboard page, select it to set its properties in Control Panel
2. Associated Events
selected Uisegmentedcontrol hold Control button to drag under @implementation viewcontroller
3. Add an event
Add a click effect within parentheses
-(ibaction) Scvaluechange: ( Uisegmentedcontrol *) sender{
{
int currentindex = sender. Selectedsegmentindex ; // the currently selected split pointer
nsstring *title = [Sender titleforsegmentatindex : Currentindex]; // the title of the selected row
NSLog (@ "%@", title);
}
Lan Yi Education September 30 record