我已经创建了一个通用方法方法来显示警报 View 。我附上了我的代码以供审查。 我正在尝试验证三个 uitextfields,如果无效,将相关信息放入 uialertview 方法中使用的实例变量中。你可以看到我在代码中散布了大量的 nslog 语句。方法开头和结尾的 nslogs 都显示发生错误的相关信息。当我单击模拟器屏幕中的按钮以启动它时,没有显示任何消息,但屏幕背景为浅灰色,将变为深灰色。
代码如下:
- (void)SendErrorMessage
{
NSLog(@"Starting SendErrorMessage");
NSLog(@"initWithTitle = %@", self.alertViewTitleText);
NSLog(@"message = %@", self.alertViewMessageText);
NSLog(@"cancelButtonTitle = %@", self.alertViewCancelButtonText);
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:self.alertViewTitleText
message:self.alertViewMessageText
delegate:nil cancelButtonTitle:
self.alertViewCancelButtonText
otherButtonTitles:nil];
[alert show];
NSLog(@"Finished SendErrorMessage");
return;
}
如有任何帮助,我们将不胜感激。
好的,
我现在很迷茫。我进入代码并在 [alert show] 下方添加了以下代码: //阻塞 5 秒 [NSThread sleepForTimeInterval:5.0];
我这样做是为了查看 alertview 是否真的快速显示以供查看。不,根据我的日志,程序停留了 5 秒,然后继续执行程序逻辑。我还将 uialertview 替换为 一个 uiactionsheet,看看它是否会显示 uialertview 不显示的地方。再一次,不,它们都不会显示在模拟器屏幕上。
这是我的 .h 文件中的接口(interface)语句:
@interface BeginningScene : UIViewController,
(小于)UIActionSheetDelegate,
UITextViewDelegate,
UIAlertViewDelegate(大于)
再次感谢您的帮助,我们将不胜感激任何想法。
最佳答案
你确定这是在主线程上运行吗? 调用 sendErrorMessage 时尝试使用它
[self performSelectorOnMainThread:@selector(sendErrorMessage)];
跳过返回语句,它没有用。
无论如何,尝试这段代码并将该方法也复制到您的头文件中,注意小写 S,只是一种偏好。
- (void)sendErrorMessage
{
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Title"
message:@"message"
delegate:nil cancelButtonTitle:
@"OK"
otherButtonTitles:nil];
[alert show];
[alert release]; // if you are not using ARC
}
关于objective-c - UIAlertView 不显示在 iphone 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12587276/
类classAprivatedeffooputs:fooendpublicdefbarputs:barendprivatedefzimputs:zimendprotecteddefdibputs:dibendendA的实例a=A.new测试a.foorescueputs:faila.barrescueputs:faila.zimrescueputs:faila.dibrescueputs:faila.gazrescueputs:fail测试输出failbarfailfailfail.发送测试[:foo,:bar,:zim,:dib,:gaz].each{|m|a.send(m)resc
我得到了一个包含嵌套链接的表单。编辑时链接字段为空的问题。这是我的表格:Editingkategori{:action=>'update',:id=>@konkurrancer.id})do|f|%>'Trackingurl',:style=>'width:500;'%>'Editkonkurrence'%>|我的konkurrencer模型:has_one:link我的链接模型:classLink我的konkurrancer编辑操作:defedit@konkurrancer=Konkurrancer.find(params[:id])@konkurrancer.link_attrib
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
我已经从我的命令行中获得了一切,所以我可以运行rubymyfile并且它可以正常工作。但是当我尝试从sublime中运行它时,我得到了undefinedmethod`require_relative'formain:Object有人知道我的sublime设置中缺少什么吗?我正在使用OSX并安装了rvm。 最佳答案 或者,您可以只使用“require”,它应该可以正常工作。我认为“require_relative”仅适用于ruby1.9+ 关于ruby-主要:Objectwhenrun
如果您尝试在Ruby中的nil对象上调用方法,则会出现NoMethodError异常并显示消息:"undefinedmethod‘...’fornil:NilClass"然而,有一个tryRails中的方法,如果它被发送到一个nil对象,它只返回nil:require'rubygems'require'active_support/all'nil.try(:nonexisting_method)#noNoMethodErrorexceptionanymore那么try如何在内部工作以防止该异常? 最佳答案 像Ruby中的所有其他对象
所以我在关注Railscast,我注意到在html.erb文件中,ruby代码有一个微弱的背景高亮效果,以区别于其他代码HTML文档。我知道Ryan使用TextMate。我正在使用SublimeText3。我怎样才能达到同样的效果?谢谢! 最佳答案 为SublimeText安装ERB包。假设您安装了SublimeText包管理器*,只需点击cmd+shift+P即可获得命令菜单,然后键入installpackage并选择PackageControl:InstallPackage获取包管理器菜单。在该菜单中,键入ERB并在看到包时选择
我试图在索引页中创建一个超链接,但它没有显示,也没有给出任何错误。这是我的index.html.erb代码。ListingarticlesTitleTextssss我检查了我的路线,我认为它们也没有问题。PrefixVerbURIPatternController#Actionwelcome_indexGET/welcome/index(.:format)welcome#indexarticlesGET/articles(.:format)articles#indexPOST/articles(.:format)articles#createnew_articleGET/article
我是rails的新手,想在form字段上应用验证。myviewsnew.html.erb.....模拟.rbclassSimulation{:in=>1..25,:message=>'Therowmustbebetween1and25'}end模拟Controller.rbclassSimulationsController我想检查模型类中row字段的整数范围,如果不在范围内则返回错误信息。我可以检查上面代码的范围,但无法返回错误消息提前致谢 最佳答案 关键是您使用的是模型表单,一种显示ActiveRecord模型实例属性的表单。c
目前,Itembelongs_toCompany和has_manyItemVariants。我正在尝试使用嵌套的fields_for通过Item表单添加ItemVariant字段,但是使用:item_variants不显示该表单。只有当我使用单数时才会显示。我检查了我的关联,它们似乎是正确的,这可能与嵌套在公司下的项目有关,还是我遗漏了其他东西?提前致谢。注意:下面的代码片段中省略了不相关的代码。编辑:不知道这是否相关,但我正在使用CanCan进行身份验证。routes.rbresources:companiesdoresources:itemsenditem.rbclassItemi
如果我在模型中设置验证消息validates:name,:presence=>{:message=>'Thenamecantbeblank.'}我如何让该消息显示在闪光警报中,这是我迄今为止尝试过的方法defcreate@message=Message.new(params[:message])if@message.valid?ContactMailer.send_mail(@message).deliverredirect_to(root_path,:notice=>"Thanksforyourmessage,Iwillbeintouchsoon")elseflash[:error]