调用[self presentViewController]一个实例UIAlertController立即加载警报。有没有办法延迟它的呈现?
[self presentViewController:alert animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud) 我创建了一个UIAlertController这样的,我想更改后退按钮(action1)的文本颜色。我该怎么做?
当我更新代码时,它起作用了,但是当按下按钮时,文本变为蓝色。
@IBAction func Horario(sender: AnyObject) {
let alert = UIAlertController(title: "Horario de Apertura", message: "\(horario)", preferredStyle: UIAlertControllerStyle.Alert)
let action1 = UIAlertAction(title: "Atrás", style: UIAlertActionStyle.Cancel, handler: nil)
alert.view.tintColor = UIColor.redColor()
alert.addAction(action1)
self.presentViewController(alert, animated: true, completion: nil);
}
Run Code Online (Sandbox Code Playgroud) 是否可以创建一个 UIAlertController,它有一个最初被禁用的按钮,然后是 5 然后是 4 然后是 3..2..1 然后启用。
我希望用户实际阅读控制器内的消息,我认为这会很烦人,实际上阻止他们盲目点击“确定”
如果可能的话,我将如何开始这样做?
谢谢
我制作了一个这样的 ActionSheet:
现在我想改变颜色Cancel并Delete给人一种感觉disabled。
我可以更改所有按钮的颜色,但不能更改个人的颜色。
我已经使用类别尝试,但我不断收到warining这ActionSheet是Depreciated。而且代码也不起作用。
我写了这个代码:
- (void)setButton:(NSInteger)buttonIndex toState:(BOOL)enabled {
for (UIView* view in self.subviews)
{
if ([view isKindOfClass:[UIButton class]])
{
if (buttonIndex == 0) {
if ([view respondsToSelector:@selector(setEnabled:)])
{
UIButton* button = (UIButton*)view;
button.enabled = enabled;
}
}
buttonIndex--;
}
}
}
Run Code Online (Sandbox Code Playgroud)
是否可以对Action sheet通过AlertViewController.
下面是我的代码来呈现动作表:
UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:@"Action Sheet" message:@"Using the alert controller" preferredStyle:UIAlertControllerStyleActionSheet];
[actionSheet.view setTintColor:[UIColor redColor]];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault …Run Code Online (Sandbox Code Playgroud) 我正在使用 PopoverController 并且我想摆脱背景阴影。苹果表示,要继承和UIPopoverBackgroundView回报false为override class var wantsDefaultContentAppearance: Bool { get }
我将其子类化并将布尔值设置为false但阴影仍然显示。如何将此子类连接到我在 LogoutClass 的 Actionsheet 中使用的 PopoverController?
UIPopoverBackgroundView 子类:
class PopoverBackgroundView: UIPopoverBackgroundView {
override class var wantsDefaultContentAppearance: Bool {
get {
return false
}
}
}
Run Code Online (Sandbox Code Playgroud)
登出控制器:
class LogoutController:UIViewController{
fileprivate func logOff(){
let actionSheet = UIAlertController(title: nil, message: "Logging out?", preferredStyle: .actionSheet)
let logout = UIAlertAction(title: "Log Out", style: .default){
(action) in
//bla bla bla
}
actionSheet.addAction(logout)
if let popoverController = actionSheet.popoverPresentationController{
popoverController.sourceView = view …Run Code Online (Sandbox Code Playgroud) uiactionsheet uipopovercontroller ios swift uialertcontroller
我是 iOS 编程的新手,我已经实现了 UITableViewController 并在我的主页上像弹出窗口一样获得了 tableViewController 设计,背面我在主页和 tableViewController 之间添加了模糊效果。模糊效果视图和 UITableView 都作为子视图添加到主屏幕中。
这是我的问题:
当我验证 tableViewController 的 UITextfields 时,alertController 出现在模糊效果和 tableViewController 的背面,我需要在 tableViewController 上使用它。
我怎样才能得到??
我使用下面的代码来实现模糊效果和 tableView:
UIVisualEffect *blurEffect;
blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
visualEffectView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
[[UIApplication sharedApplication].keyWindow addSubview:visualEffectView];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
viewaccept = (AcceptViewController *)[storyboard instantiateViewControllerWithIdentifier:@"AcceptViewController"];
[viewaccept willMoveToParentViewController:self];
CGRect screen = [[UIScreen mainScreen] bounds];
CGRect newFrame = CGRectMake(0,screen.size.height/4, self.view.frame.size.width, 350);
UIEdgeInsets insets = UIEdgeInsetsMake(0,10,0,10);
viewaccept.view.frame = UIEdgeInsetsInsetRect(newFrame,insets);
CGRect splitframe = …Run Code Online (Sandbox Code Playgroud) 现在我收到错误:警告:尝试在 CollectionViewController 上呈现 UIAlertController:0x7f9af9016200:0x7f9af750d620 已经呈现(空)
有没有办法快速堆叠警报?有我的代码,如果项目发布时间超过一天,它会显示警报。我尝试过两种方法但没有成功。
任何解决方案如何管理做到这一点?
for p in json! {
if self.checkDaysPassed(postDate: p["uploadedTime"] as! String) > 1 {
print("more than one day passed, sell item?")
let alert = UIAlertController(title: "Sell this item", message: "This item has been unused for a day", preferredStyle: .alert)
alert.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
alert.addAction(UIAlertAction(title: "Yes", style: .default){ (action) in
print("pressed yes")
})
alert.addAction(UIAlertAction(title: "No", style: .cancel){ (action) in
print("pressed no")
})
self.present(alert, animated: true)
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个应用程序可以一次从服务器下载许多出版物。对于应用程序中已经存在的每个出版物,我想提示用户是否要覆盖现有版本。
是否有任何干净的方式来呈现 UIAlertControllers,以便当用户回答一个时,应用程序呈现下一个?
假设 ViewController2 中有错误,我想回到 ViewController1,前一个视图控制器,然后显示警报。现在如果我把它放在 ViewController2 中
@IBAction func testing(_ sender: Any) {
navigationController?.popViewController(animated: true)
Alert.alert(userTitle: "Error", userMessage: " ", userOptions: " ", in: LandingViewController() as UIViewController)
}
Run Code Online (Sandbox Code Playgroud)
使用它作为警报类
public class Alert {
class func alert(userTitle: String?, userMessage: String, userOptions: String, in vc: UIViewController) {
DispatchQueue.main.async {
let alert = UIAlertController(title: userTitle, message: userMessage, preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: userOptions, style: UIAlertActionStyle.default, handler: nil))
vc.present(alert, animated: true, completion: nil)
}
}
}
Run Code Online (Sandbox Code Playgroud)
它会抛出错误
那么有没有办法做到这一点?
我正在尝试在 iOS 应用程序的操作表中添加图标。我在AppStore的action sheet中看到apple已经实现了这样的行为,但是没有提供任何回调方法来实现它?
关于如何在 iOS 12 Swift 4.x Xcode10.x 上实现它的任何建议?