uiactionsheet 内に Uiswitch を実装しています。必要な場所に配置できましたが、使用する方法がありませんでした。ここに私のコードがあります:
switchButton = [[UISwitch alloc] init];
[mySheet addSubview:switchButton];
[mySheet showInView:self.view];
UILabel *instruction = [[UILabel alloc] init];
[instruction setBackgroundColor:[UIColor clearColor]];
[instruction setText:@"Daily"];
[mySheet addSubview:instruction];
// get the dimension of the sheet to position the switch
CGSize parentSize = mySheet.frame.size;
CGRect rect = switchButton.frame;
rect.origin.x = parentSize.width/2.0 - rect.size.width + 90;
rect.origin.y = parentSize.height - rect.size.height + 90 ;
switchButton.frame = rect;
//get the dimension of the sheet to possition the label
rect.origin.x = parentSize.width/2.0 - rect.size.width -20;
rect.origin.y = parentSize.height - rect.size.height + 90 ;
instruction.frame = rect;
スイッチ ボタンを ioutlet として初期化しました。アクションシートの機能では、これをやろうとしています。
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex: (NSInteger)buttonIndex{
switch (buttonIndex) {
case 0:
{
NSLog(@"Yes Button is working");
}
break;
case 1:
{
if(switchButton.on){
NSLog(@"IS on ?");
}
else {
NSLog(@"Is off?");
}
}
default:
break;
}
**IMP 「-(ibAction)funct」を作成したものをさらに試してみましたが、これを行ったときに、これをスイッチにリンクすることができませんでした **