我需要知道iOS中是否存在任何与Android中的Toast消息相似的方法.也就是说,我需要显示一条消息,该消息在几秒钟后自动被解除.这类似于Android环境中Toast类的功能.
我尝试了几种方法来使用UIAlertController而不是UIAlertView.我尝试了几种方法,但我无法使警报行动起作用.这是我的代码在IOS 8和IOS 9中正常工作,但是出现了弃用的标志.我尝试了下面的优雅建议,但我无法在此背景下使其发挥作用.我需要提交我的应用程序,这是最后要解决的问题.感谢您的任何进一步建议.我是新手.
#pragma mark - BUTTONS ================================
- (IBAction)showModesAction:(id)sender {
NSLog(@"iapMade: %d", iapMade3);
// IAP MADE ! ===========================================
if (!iapMade3) {
//start game here
gamePlaysCount++;
[[NSUserDefaults standardUserDefaults]setInteger:gamePlaysCount forKey:@"gamePlaysCount"];
NSLog(@"playsCount: %ld", (long)gamePlaysCount);
if (gamePlaysCount >= 4) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Basic"
message: THREE_PLAYS_LIMIT_MESSAGE
delegate:self
cancelButtonTitle:@"Yes, please"
otherButtonTitles:@"No, thanks", nil];
[alert show];
NSString *path = [[NSBundle mainBundle] pathForResource:@"cow" ofType:@"wav"];
_pop =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
[_pop play];
[self dismissViewControllerAnimated:true completion:nil];
} else {
if (gamePlaysCount == 1) {
// Create …Run Code Online (Sandbox Code Playgroud) 当您想要回复邮件时,我想创建一个类似于邮件应用程序中的弹出菜单.我在多个应用程序中看到过这个,所以我不确定框架中是否有内置的东西或者那些示例代码.

无法找到一个明确和翔实的解释.
如何使用Swift创建自定义警报?我尝试从Objective c翻译指南但加载全屏布局
为了方便我可以加载透明背景的新布局我试试这个:
listaalertviewcontroller.view.backgroundColor = UIColor.clearColor()
let purple = UIColor.purpleColor() // 1.0 alpha
let semi = purple.colorWithAlphaComponent(0.5)
listaalertviewcontroller.view.backgroundColor = semi
presentingViewController.modalPresentationStyle = UIModalPresentationStyle.CurrentContext
self.presentViewController(listaalertviewcontroller, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
在动画中它是透明的,但是当动画结束时它是不透明的......我在视图中关闭了不透明的选项......我做错了什么?
我正在使用带有代码的ViewController(没有故事板).我正在尝试添加和AlertController
我已经在.m中声明了
@property (nonatomic, strong) UIAlertController *alertController;
Run Code Online (Sandbox Code Playgroud)
并在loadview方法中初始化
//alertviewController
_alertController = [[UIAlertController alloc]initWithNibName:nil bundle:nil];
Run Code Online (Sandbox Code Playgroud)
并在viewDidLoad以下位置调用alertview :
_alertController = [UIAlertController alertControllerWithTitle:@"Error display content" message:@"Error connecting to server, no local database" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
LandingPageViewController *viewController = [[LandingPageViewController alloc] initWithNibName:nil bundle:nil];
// viewController.showNavBarBackButton = YES;
[[AppDelegate sharedAppDelegate].rootViewController cPushViewController:viewController];
}];
[_alertController addAction:ok];
[self presentViewController:_alertController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
我不知道为什么警报没有显示出来.我的代码出了点问题.如何以alertViewController编程方式设置和调用?
我试图在我的快速应用程序中显示UIAlertView
alert = UIAlertView(title: "",
message: "bla",
delegate: self,
cancelButtonTitle: "OK")
alert!.show()
Run Code Online (Sandbox Code Playgroud)
=> BAD_ACESS错误: - [_ UIAlertViewAlertControllerShim initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:]()
所以我怀疑自己.我把它设置为零
alert = UIAlertView(title: "",
message: "bla",
delegate: nil,
cancelButtonTitle: "OK")
alert!.show()
Run Code Online (Sandbox Code Playgroud)
=> ARM_DA_ALIGN错误: - [_ UIAlertViewAlertControllerShim initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:]()
完整的代码
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UIAlertViewDelegate {
@lazy var window = UIWindow(frame: UIScreen.mainScreen().bounds)
@lazy var locationManager = CLLocationManager()
var alert: UIAlertView? = nil
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
//setup dummy window
self.window.backgroundColor = UIColor.whiteColor()
self.window.rootViewController = UIViewController() …Run Code Online (Sandbox Code Playgroud) 看起来alertstatus不能在swift中使用.
你能帮助我实现下面代码的替代解决方案吗?
[self alertStatus:@"Message!" :@"Alert title" :0];
Run Code Online (Sandbox Code Playgroud) 我正在学习在Flutter中构建应用程序。现在我来警报对话框。我之前在Android和iOS中完成过这些操作,但是如何在Flutter中发出警报?
以下是一些相关的SO问题:
我想进行更一般的规范问答,所以我的答案如下。
ios ×7
swift ×5
uialertview ×5
objective-c ×4
android ×1
cocoa-touch ×1
dart ×1
dialog ×1
flutter ×1
ios8 ×1
popup ×1
uiview ×1