我需要在用戶點擊按鈕時顯示帶有UISwitch的「彈出」按鈕,並在點擊彈出窗口中的完成按鈕時保存開關的狀態。UIActionSheet中的控件定位錯誤
於是我就用UIActionSheet做到這一點 - 這一切
sheet = [[UIActionSheet alloc] initWithTitle:@"Switch Setting"
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:@"Done", nil];
theSwitch = [[UISwitch alloc] init];
[sheet addSubview:theSwitch];
[sheet showInView:self.view];
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == actionSheet.firstOtherButtonIndex)
{
theSwitch .on? NSLog(@"Switch is on") : NSLog(@"Switch if off");
}
}
的偉大工程。我有定位問題。不幸的是,我現在沒有屏幕截圖在這裏發佈。但是開關出現在操作表標題的同一行的最上方,然後在下方顯示完成按鈕。
請別人幫助我如何將開關置於標題下方並增加操作表尺寸,使其看起來整潔。我需要這個儘快。謝謝。