【发布时间】:2010-03-20 17:57:08
【问题描述】:
当用户点击按钮时,我需要显示一个带有 UISwitch 和完成按钮的弹出窗口,并在点击弹出窗口中的完成按钮时保存开关的状态。
所以我使用 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");
}
}
这一切都很好。我有定位问题。不幸的是,我目前没有可以在此处发布的屏幕截图。但是开关出现在与操作表标题相同的行的最顶部,然后是完成按钮。
请有人帮助我如何将开关放置在标题下方并增加操作表的大小以使其看起来整洁。我需要这个尽快。谢谢。
【问题讨论】:
标签: objective-c ipad orientation subview uiactionsheet