我想显示从最顶部状态栏下方滑动的操作表.
当我使用navigationBar作为要显示的视图时,工作表仍然显示在屏幕的底部.我怎样才能显示它来自顶部呢?
我正在调用以下代码的类是'UIViewController'
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"Hello" delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
UINavigationBar *navBar = self.navigationController.navigationBar;
[sheet showInView:navBar];
Run Code Online (Sandbox Code Playgroud)
我已经看到一些应用程序显示了状态栏所在的某种抽屉式抽屉.(例如:Twitterrific)这是怎么做到的?
我正在编写一些Objective-C代码,而且我经常遇到必须使用类变量来存储一次使用值的情况.消费后我不再需要它了.对我来说,将这个值存储在类变量中似乎是代码味道.确实应该将值作为参数传递给我正在使用的方法.
当我正在消费代表时,我经常遇到这种情况.作为一个例子,我有一个带有多个按钮的UI,用于加载和显示UIActionSheet它们被点击的时间.此操作表包含一个日期选择器,用于设置UILabel解除操作表单时的值.
- (IBAction)setPurchaseDateTapped {
self.activeField = purchaseDate;
[self loadDatePickerActionSheet:@"Edit Purchase Date"];
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
self.activeField.text = value_from_UIActionSheet;
}
Run Code Online (Sandbox Code Playgroud)
正如你在这里看到的那样,actionSheet clickedButtonAtIndex回调不允许我传递,activeField所以我必须使用类变量.写这个似乎更正确:
- (void)actionSheet:(UIActionSheet *)actionSheet parameterValue:(id)parameter {
parameter.text = value_from_UIActionSheet;
}
Run Code Online (Sandbox Code Playgroud)
我相信(?)我可以继承UIActionSheet和UIActionSheet委托,并添加我需要的签名,但这似乎更值得付出努力.
所以我的问题是,做我想做的事情的最佳方法是什么?
我不一定想要更改我创建的日期选择器/操作表界面(尽管如果有一个更好的模式可以在UIView上设置多个日期同时保持DatePicker不碍事,我会全力以赴.)
我有一个运行iOS 3.2.2的iPad特定应用程序,它在ui popover中显示设置视图.这一切都很好,但现在我正在尝试在视图内部渲染日期选择器,并且不确定显示它的最佳方法是什么.
现在它有一个按钮可以切换模态中日期选择器的可见性,但与操作表的正常方法相比,这对于管理解雇来说似乎非常笨拙.
我无法找到针对这种情况的"最佳实践",并且想知道是否有人之前遇到这种情况并且可以提供一些建议或指导.
谢谢!
我想改变image of的buttons的UIActionSheet,我有images每个button了,我希望每个button显示image我想要的.我在网上搜索了我找到了很多答案,但是他们没有用.
这是初始化的 UIActionSheet
-(IBAction)showActionSheet:(id)sender {
UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:@"title" delegate:self cancelButtonTitle:@"Cancel Button" destructiveButtonTitle:nil otherButtonTitles:@"Other Button 1", @"Other Button 2", nil];
popupQuery.actionSheetStyle = UIActionSheetStyleDefault;
[popupQuery showInView:self.view];
[popupQuery release];
}
Run Code Online (Sandbox Code Playgroud) 我已阅读另一篇文章(如何解散行动表),我可以使用
[actionSheet dismissWithClickedButtonIndex:0 animated:YES];
Run Code Online (Sandbox Code Playgroud)
使用关闭按钮关闭uiactionsheet,如下所述:
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
CGRect pickerFrame = CGRectMake(0, 40, 0, 0);
UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:pickerFrame];
pickerView.showsSelectionIndicator = YES;
pickerView.dataSource = self;
pickerView.delegate = self;
[actionSheet addSubview:pickerView];
[pickerView release];
UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Close"]];
closeButton.momentary = YES;
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
closeButton.tintColor = [UIColor blackColor];
[closeButton addTarget:self action:@selector(dismissActionSheet:) forControlEvents:UIControlEventValueChanged];
[actionSheet addSubview:closeButton];
[actionSheet dismissWithClickedButtonIndex:0 animated:YES];
[closeButton release];
[actionSheet …Run Code Online (Sandbox Code Playgroud) xcode objective-c uisegmentedcontrol uipickerview uiactionsheet
我正在创建一个UIActionSheeton actionSheet:clickedButtonAtIndex委托方法.
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
if(buttonIndex == 1){
[self.myFirstView removeFromSuperview];
if (!self.mySecondView) {
[[NSBundle mainBundle] loadNibNamed:@"MySecondView" owner:self options:nil];
}
[self.mySecondView setFrame:CGRectMake(0, 0, 320, 480)];
[[UIApplication sharedApplication].keyWindow addSubview: self.mySecondView];
UIActionSheet * action = [[UIActionSheet alloc]initWithTitle:@""
delegate:self
cancelButtonTitle: nil
destructiveButtonTitle: deleteContacts
otherButtonTitles: cancel, nil];
action.tag = 102;
[action showInView:self.view];
[action release];
}
Run Code Online (Sandbox Code Playgroud)
我用UIActionSheet与上面完全相同的方法处理了click事件.
if(actionSheet.tag == 102){
if(buttonIndex == 0){
if([[NSBundle mainBundle] loadNibNamed:@"MyThirdView" owner:self options:nil]) {
[self.myThirdView setFrame:CGRectMake(0, 0, 320, 480)];
[[UIApplication sharedApplication].keyWindow addSubview:self.myThirdView];
}
[self.mySecondView removeFromSuperview];
[self.doneButton.target …Run Code Online (Sandbox Code Playgroud) 我是iphone的新手.我正在为我的项目做提醒申请.我希望从uiactionsheet.i获取输入值,如提醒标题和数据及时间,在动作表中创建了datepicker和uitextfield.动作表出现在textfield中.当我点击文本字段时,键盘出现但不起作用..当我输入时,它们在文本字段中不可见
-(void)btnSetRemainderTapped:(id)sender
{
UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:@"Select reminder date and time"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:@"Save"
otherButtonTitles:nil,nil];
menu.tag =10;
[menu showInView:self.view];
menu.userInteractionEnabled=YES;
UITextField *txtReminderTitle= [[UITextField alloc] initWithFrame:CGRectMake(20.0, 180, 280.0, 40.0)];
[txtReminderTitle setTag:99];
[txtReminderTitle setBackgroundColor:[UIColor whiteColor]];
[txtReminderTitle setFont:[UIFont boldSystemFontOfSize:17]];
[txtReminderTitle setBorderStyle:UITextBorderStyleNone];
[txtReminderTitle setTextAlignment:UITextAlignmentCenter];
txtReminderTitle.borderStyle = UITextBorderStyleRoundedRect;
txtReminderTitle.keyboardType = UIKeyboardTypeDefault;
txtReminderTitle.returnKeyType = UIReturnKeyDone;
txtReminderTitle.delegate =self;
[menu addSubview:txtReminderTitle];
UIDatePicker *pickerView = [[UIDatePicker alloc] init];
pickerView.datePickerMode = UIDatePickerModeDateAndTime;
pickerView.tag =9999;
[menu addSubview:pickerView];
CGRect menuRect = menu.frame;
NSInteger orgHeight = menuRect.size.height;
menuRect.origin.y -= 270; //height …Run Code Online (Sandbox Code Playgroud) 我是iOS开发新手,学习点点滴滴.我在iOS 7上继续使用另一个线程(iOS7:Apple如何使导航控制器看起来像日历应用程序中的uiactionsheet)的更多查询在默认日历中创建新事件,当我们在UINavigationBar上单击+时显示(我假设).
有没有人知道如何创建UIDatePicker,以便在我点击开始/结束日期字段时显示/隐藏它?我看到一个视频,其中UIActionSheet在XCode 4.5中使用,但是用户需要点击Done etc按钮来隐藏它.在iOS 7日历中,当我点击外部选择器时,即在"开始日期"字段中隐藏它.我希望问题清楚吗?
请建议如何实现此功能?
是否可以使用UIActionSheetiOS 7的tintColor颜色按钮?我的意思是如果我的应用程序是品牌tintColor,例如红色,我不想在行动表中使用蓝色按钮.同样的UIAlertView.
我有一个带有一些选项的按钮.
- (IBAction)monstrarActionSheet:(id)sender {
UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:@"Titulo"
delegate:self
cancelButtonTitle:@"Mejor no" destructiveButtonTitle:@"Que miedo" otherButtonTitles:@"Otro boton 1", @"Otro boton 2", nil];
[action showInView: self.view];
Run Code Online (Sandbox Code Playgroud)
选择某个选项后,我会在日志中显示一条消息,以显示选择了哪个按钮.
-(void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
/*if(actionSheet.tag == 1){
}*/
NSLog(@"El usuario seleciono el boton %ld", (long)buttonIndex);
}
Run Code Online (Sandbox Code Playgroud)
在我的ViewController.h我的按钮和标签是这样定义的
@interface ViewController : UIViewController <UIActionSheetDelegate>
@property (weak, nonatomic) IBOutlet UILabel *lbViewController1;
Run Code Online (Sandbox Code Playgroud)
如何将所选UIActionSheet按钮的标题放入我的lbViewController1标签中?
uiactionsheet ×10
ios ×6
iphone ×5
objective-c ×4
ipad ×2
uidatepicker ×2
calendar ×1
cocoa-touch ×1
delegates ×1
ios7 ×1
uipickerview ×1
uiview ×1
xcode ×1