我用input accessory view我的viewController在屏幕的底部停靠视图,并在键盘坚持.
一切正常,除了显示一个alert,input accessory view隐藏.它再次被揭露解雇了alert.这导致不期望的故障.
我尝试使用[alertView show]API和新alertControllerAPI.两种情况都存在问题.我需要得到支持iOS7.0.
请提供您宝贵的意见或解决此问题的方法.
我的应用程序有一个UILongPressGestureRecognizer,UIAlertController当用户触摸屏幕上的两个元素时,它会显示警报.目前,用户必须按下OK按钮才能解除警报,但是我想在0.5秒后自动关闭警报,因此用户不会损害他与应用程序的交互.
有没有办法做到这一点?
我使用警报控制器创建了一个弹出警报,并添加了两个警报操作(确定和取消),如下所示.
UIAlertController * alert= [UIAlertController
alertControllerWithTitle:@"Cycling"
message:@"Please enter title and description"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction
actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[alert dismissViewControllerAnimated:YES completion:nil];
}];
UIAlertAction* cancel = [UIAlertAction
actionWithTitle:@"Cancel"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[alert dismissViewControllerAnimated:YES completion:nil];
}];
[alert addAction:ok];
[alert addAction:cancel];
[self presentViewController:alert animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
现在,我想添加UITextView.因为我有两个文本字段,如标题和描述.为了描述我想使用UITextView添加no.of行.我试过我没有得到如何添加它.
请指教.
我想在UIAlertController或UIPopoverController中显示UIPickerView,我是iOS新手,请在这里给我一些示例代码.
我搜索了他们但找不到任何满意的答案.我不想在UIActionSheet上这样做,因为它在iOS 9中已被弃用.我也希望它在Swift中而不是在Obj-C中.我尝试了下面的例子,但它不适合我.
http://makeapppie.com/2014/08/30/the-swift-swift-tutorials-adding-modal-views-and-popovers/
uipickerview uipopovercontroller ios swift uialertcontroller
我想向用户提供一个简单的UIAlertController,其中一个选项触发关闭父视图控制器.这是我正在使用的代码:
let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Close View", style: UIAlertActionStyle.Destructive, handler: {
action in
self.dismissViewControllerAnimated(true, completion: nil)
}))
alert.addAction(UIAlertAction(title: "CANCEL", style: UIAlertActionStyle.Cancel, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
它没有任何影响.执行"关闭视图"处理程序后,显示警报的视图控制器仍然存在.
我也尝试self.navigationController?.dismissViewControllerAnimated(true, completion: nil)过UIAlertAction动作块但是也没用.
我需要在UIAlertController出现后立即选择文本字段的文本.但是,我在标准UITextField中选择文本的方式在此处不起作用.
这就是我尝试过的,但我似乎无法让它发挥作用.
let ac = UIAlertController(title: "Rename", message: nil, preferredStyle: .Alert)
ac.addTextFieldWithConfigurationHandler({
[] (textField: UITextField) in
textField.selectedTextRange = textField.textRangeFromPosition(textField.beginningOfDocument, toPosition: textField.endOfDocument)
textField.text = "filename.dat"
})
ac.addAction(UIAlertAction(title: "CANCEL", style: .Cancel, handler: nil))
ac.addAction(UIAlertAction(title: "OK", style: .Default, handler: {
[] Void in
// do something
}))
dispatch_async(dispatch_get_main_queue(), {
self.presentViewController(ac, animated: true, completion: nil)
})
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
在我的应用程序中,我只有一个UIViewController横向模式,如果我在应用程序中导航它就可以正常工作。但是当我UIAlertController从该横向视图控制器呈现(用于显示警报视图)并更改设备方向时,它会更改该横向视图控制器的方向。我尝试了不同的解决方案,例如:
但这些都不适合我。如何锁定UIAlertController的方向?注意:我的应用程序支持iOS9.
UIAlertController自定义字体不起作用.
以下代码是一个函数ShowActionSheetAsync,show ActionSheet.此时,我想改变字体ActionSheet.我尝试了几种方法,但效果不佳.有好的解决方案吗?
public Task<bool> ShowActionSheetAsync()
{
var source = new TaskCompletionSource<bool>();
var alert = new UIAlertController
{
Title = "title"
};
alert.AddAction(UIAlertAction.Create(
"button1",
UIAlertActionStyle.Default,
_ => source.SetResult(true)));
alert.AddAction(UIAlertAction.Create(
"cancel",
UIAlertActionStyle.Cancel,
_ => source.SetResult(false)));
// [Block 1]
var viewController = UIApplication.SharedApplication.KeyWindow.RootViewController;
ViewController.PresentViewController(alert, true, delegate
{
// [Block 2]
});
// [Block 3]
return source.Task;
}
Run Code Online (Sandbox Code Playgroud)
首次尝试 以下代码无法正常运行.
当我把代码放在[Block 1]或[Block 2]
当我把代码放在上面 [Block 3]
ActionSheet.从第二次起,它不起作用
UILabel.AppearanceWhenContainedIn(typeof(UIActionSheet)).Font
= UIFont.FromName(StyleResources.MediumFontName, 20);
第二次尝试 …
我需要显示一个没有提交按钮的框,但让它在3秒后消失.是否可以附加任何超时?
UIAlertController * alert= [UIAlertController
alertControllerWithTitle:@"Please wait, checking your PAID INVOICE, to allow the service."
message:"...waiting..."
preferredStyle:UIAlertControllerStyleAlert];
[self.window.rootViewController presentViewController:alert animated:YES
completion:nil];
Run Code Online (Sandbox Code Playgroud) 我用 UIAlertControllerStyleActionSheet 风格显示 UIAlertController 。使用 XCode 13 UIAlertController 标题和消息构建时,在 iPhone 12 上不起作用。它在其他设备上工作。之前在 iPhone 12 上运行的代码相同。
-(void)alertSheetUI{
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:@"Static Title" message:@"Static Message" preferredStyle:UIAlertControllerStyleActionSheet];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Data 1" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Data 2" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Data 3" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
[[[UIApplication sharedApplication] delegate].window.rootViewController dismissViewControllerAnimated:YES completion:^{
}];
}]];
[[[UIApplication sharedApplication] delegate].window.rootViewController presentViewController:actionSheet animated:NO completion:nil];
});}
Run Code Online (Sandbox Code Playgroud)
iPhone 12
视图层次结构将标题和消息显示为白色。所以只有标题和消息不可见。我尝试使用以下代码将标题和消息设置为绿色使用属性文本。但标题和消息颜色在其他设备上也不会更新。其他设备显示为灰色。 …
ios ×8
swift ×5
objective-c ×4
c# ×1
ios9 ×1
iphone ×1
uialertview ×1
uipickerview ×1
xamarin.ios ×1
xcode13 ×1