草庐IT

ios - XCode 6 - iOS 8 : programmatically check if view is installed

我在界面构建器中使用类大小,为不同的大小定义略有不同的设计。我的观点之一是未安装特定尺寸。这按预期工作,但现在我想以编程方式能够判断是否安装了该View。无论是否安装,看起来View永远不会为零,而且我看不到任何要检查的isInstalled标志。正确的做法是什么? 最佳答案 这不是一个很好的解决方案,但我还没有找到更好的解决方案:docs声明“仍会创建已卸载View的运行时对象。但是,View和任何相关约束都不会添加到View层次结构中,并且View的superView属性为nil”。因此,对有效superView的测试可以作为一

ios - UICollectionView performBatchUpdates : asserts unexpectedly if view needs layout?

如果我从viewWillAppear:内部、viewDidAppear:内部、这些方法之间或集合的任何时间调用-[UICollectionViewperformBatchUpdates:]View没有被更大的UIViewView层次结构布局,CollectionView将断言:***Terminatingappduetouncaughtexception'NSInternalInconsistencyException',reason:'Invalidupdate:invalidnumberofsections.Thenumberofsectionscontainedinthecoll

iphone - 如何在 if 中比较 NSNumber

如何:if(myNSNumber==1){...}这似乎没有建立对象: 最佳答案 如果myNSNUber是NSNumber,你的代码应该是这样的,if([myNSNumberintValue]==1){...}如果是NSInteger,可以直接和整型字面量比较。因为NSInteger是原始数据类型。if(myNSNumber==1){...}注意:确保您的声明中没有*。你的NSInteger声明应该是这样的,NSIntegermyNSNUmber;//RIGHTNSInteger*myNSNUmber;//WRONG,NSInteg

ios - prepareForSegue : how can I set an if-condition?

这可能是非常新手但是...我在我的Storyboard中的两个ViewControllers之间设置了一个segue,标识符为clickBtn。现在我在我的代码中这样调用它:-(void)prepareForSegue:(UIStoryboardSegue*)seguesender:(id)sender{if([[segueidentifier]isEqualToString:@"clickBtn"]){if(conditionVerified){SecondViewController*controller=(SecondViewController*)segue.destinati

iOS 7 SLComposeViewController : Check if tweet was actually posted?

我目前正在使用SLComposeViewController将用户的分数发布到Twitter或Facebook(取决于他们点击的按钮)。当他们分享时,他们将获得虚拟货币奖励。我面临的问题是它只会告诉我用户是点击发送还是取消。我如何检查推文是否实际发布到推特上?这将有助于解决用户尝试两次提交同一条推文的情况(推特不允许)。这是我现在的代码://Checkifusercansendtweetif([SLComposeViewControllerisAvailableForServiceType:SLServiceTypeTwitter]){SLComposeViewController*t

ios - 原因 - (void)cancelTrackingWithEvent :(UIEvent *)event getting called If I am using MSSlideNavigationController?

我尝试在我的ViewController中使用自定义UIControl。我的自定义类是UIControl的子类,并为我的自定义控件分配实例并通过以下代码添加到我的ViewController的View中CustomControl*customControl=[[CustomControlalloc]initWithFrame:CGRectMake(44,388,235,160)];[self.viewaddSubview:customControl];然后我在CustomControl中实现以下委托(delegate)方法-(BOOL)beginTrackingWithTouch:(U

iOS 解析 SDK : How to check if login is from Facebook or Twitter?

我有一个允许用户登录Facebook或Twitter的应用程序。有一个-(void)logInViewController:(PFLogInViewController)logInControllerdidLogInUser:(PFUser)user管理从PFLogInViewController登录的方法。如何检查用户是否按下了Facebook登录按钮或Twitter登录按钮?我的应用程序中有一些功能需要根据登录类型进行不同的设置。 最佳答案 在logInViewController:didLogInUser:中……检查一下BOO

ios - 核心蓝牙 : Getting error even if data is written into writable characteristics

我正在使用CoreBlueTooth框架写入Peripheral的可写特性之一。我在中央实现“didWriteValueForCharacteristic:错误:”委托(delegate),它总是在错误之下返回我。尽管我已经在我的外围设备上收到了数据。ErrorDomain=CBErrorDomainCode=0"Unknownerror."UserInfo=0x166762e0{NSLocalizedDescription=Unknownerror.}在我的代码中,我的self.data是一个具有3个键和值的NSDictionary。//Central-(void)centralMa

ios - 带有 && 运算符的 If 语句检查第二个值?

如果第一个参数为false/NO&&operator检查第二个参数的if语句/?下面会崩溃吗?NSDictionary*someRemoteData=[rawJsonvalueForKey:@"data"];if([someRemoteDataisKindOfClass:[NSDictionaryclass]]&&someRemoteData.count>0){//..dosomething}请不要简单回答是或否,但请解释原因。 最佳答案 不,在得知答案将是NO后,它不会计算表达式。这称为短路,它是在C、C++、ObjectiveC

ios - UITableView 删除/添加行导致 CoreData : Serious Application Error if another object has been selected in the MasterView of a SplitViewController

更新18/3#2。我已经开始计算beginUpdates和EndUpdates以确保它们相等。就在出现异常之前,它们不同步。虽然不确定为什么。18月3日更新:我想我已经找到了问题,但我不确定我是否知道如何解决它。试验了几个小时后,我发现只有在session期间在svc的主TableView中选择了多个项目时,我才能使应用程序崩溃。当在主TableView中选择另一个项目时,详细TableView将获得一个新的对象集,并且refreshtables被调用,即使它在更新/移动/删除/插入循环的中途也是如此。因此问题;我认为它有更新旧故事对象的说明,即使在detailviewcontroll