Questions tagged «objective-c»

仅在有关Objective-C功能或取决于语言代码的问题上使用此标记。标签[cocoa]和[cocoa-touch]应该用于询问Apple的框架或类。使用相关标签[ios],[macos],[apple-watch]和[tvos]来解决特定于这些平台的问题。


3
在Objective-C中,Java的“ instanceof”关键字等效于什么?
我想检查一个对象(例如someObject)是否可分配(可广播)到另一种类型的变量(例如SpecifiedType)。在Java中,我可以这样写: someObject instanceof SpecifiedType 一个相关的问题是查找对象的运行时类型是否等于另一个类型。在Java中,我可以这样写: someObject.getClass().equals(SpecifiedType.class) 如何在Objective-C中完成?



22
Xcode-ld:-lPods找不到库
尝试构建iOS应用程序时出现这些错误。 ld: library not found for -lPods clang: error: linker command failed with exit code 1 (use -v to see invocation) Ld /Users/Markus/Library/Developer/Xcode/DerivedData/Totalbox-clpeqwpfvwuhpleeejnzlavncnvj/Build/Products/Debug-iphonesimulator/Totalbox.app/Totalbox normal x86_64 cd /Users/Markus/Development/xcode/totalbox-ios export IPHONEOS_DEPLOYMENT_TARGET=7.1 export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk -L/Users/Markus/Library/Developer/Xcode/DerivedData/Totalbox-clpeqwpfvwuhpleeejnzlavncnvj/Build/Products/Debug-iphonesimulator -F/Users/Markus/Library/Developer/Xcode/DerivedData/Totalbox-clpeqwpfvwuhpleeejnzlavncnvj/Build/Products/Debug-iphonesimulator -filelist /Users/Markus/Library/Developer/Xcode/DerivedData/Totalbox-clpeqwpfvwuhpleeejnzlavncnvj/Build/Intermediates/Totalbox.build/Debug-iphonesimulator/Totalbox.build/Objects-normal/x86_64/Totalbox.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -ObjC -framework CoreGraphics -framework Foundation -framework …

2
iOS 7+中的Base64解码
我已经NSString使用NSDataiOS7中添加的Class new API 编码了text()。 使用这个 - (NSData *)dataUsingEncoding:(NSStringEncoding)encoding; 这是我的代码 NSString *base64EncodedString = [[myText dataUsingEncoding:NSUTF8StringEncoding] base64EncodedStringWithOptions:0]; NSLog(@"%@", base64EncodedString); 我正在寻找解码
184 ios  objective-c  swift  ios7  ios8 

20
在Objective-C中检查空字符串的正确方法是什么?
我在iPhone应用程序中使用了它 if (title == nil) { // do something } 但是它会引发一些异常,并且控制台显示标题为“(null)”。 所以我现在用这个: if (title == nil || [title isKindOfClass:[NSNull class]]) { //do something } 有什么区别?确定字符串是否为null的最佳方法是什么?

12
具有UITapGestureRecognizer的视图内的UIButton
我有一个观点UITapGestureRecognizer。因此,当我点击视图时,该视图上方会出现另一个视图。此新视图具有三个按钮。现在,当我按下这些按钮之一时,我没有得到按钮动作,只有击打手势动作。因此,我无法再使用这些按钮。我该怎么做才能使事件通过这些按钮?奇怪的是按钮仍然突出显示。 收到UITapGestureRecognizer的提示后,我不能只删除它。因为有了它,新视图也可以被删除。意味着我想要像全屏视频控件那样的行为。

4
禁用某些文件的自动引用计数
我已经下载了iOS 5 SDK,并发现ARC是新Apple编译器的一项强大功能。目前,许多第三方框架不支持ARC。我可以使用ARC作为新代码并保持当前的保留/发布代码不变吗?ARC转换器在这里不起作用,因为某些框架(例如JSONKit)无法使用该转换器转换为ARC。 编辑: 答案是为-fno-objc-arc不需要ARC的文件添加到编译器标志。在Xcode 4中,您可以在目标->构建阶段->编译源代码下执行此操作。

8
如何从课堂上以编程方式加载情节提要?
我的问题是我正在寻找同时使用情节提要和xib的方法。但是我找不到以编程方式加载和显示情节提要的正确方法。该项目是从xib开始开发的,现在很难将所有xib文件嵌套在情节提要中。所以我一直在寻找一种在代码中实现它的方法,就像使用alloc, init, pushviewControllers一样。就我而言,情节提要中只有一个控制器:UITableViewController,它具有静态单元格,其中包含一些我想显示的内容。如果有人知道在不进行大量重构的情况下使用xib和Storyboard的正确方法,我将不胜感激。

19
如何判断UITableView何时完成ReloadData?
执行完后,我试图滚动到UITableView的底部 [self.tableView reloadData] 我原来有 [self.tableView reloadData] NSIndexPath* indexPath = [NSIndexPath indexPathForRow: ([self.tableView numberOfRowsInSection:([self.tableView numberOfSections]-1)]-1) inSection: ([self.tableView numberOfSections]-1)]; [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES]; 但是后来我读到reloadData是异步的,因此自以来都没有发生滚动self.tableView,[self.tableView numberOfSections]并且[self.tableView numberOfRowsinSection都为0。 谢谢! 奇怪的是我正在使用: [self.tableView reloadData]; NSLog(@"Number of Sections %d", [self.tableView numberOfSections]); NSLog(@"Number of Rows %d", [self.tableView numberOfRowsInSection:([self.tableView numberOfSections]-1)]-1); 在控制台中,它返回Sections = 1,Row = -1; 当我执行完全相同的NSLogs时,cellForRowAtIndexPath我得到Sections = 1和Row = …



10
UIImageView方面适合和居中
我有一个以编程方式声明的图像视图,并且正在以编程方式设置其图像。 但是,我发现自己无法将图像设置为既适合纵横比又使中心与图像视图对齐。 换句话说,我希望图像能够: 如果图像较大,请缩小以适合外观。 如果图像较小,请居中但不要放大。 我怎么得到的?

1
如何在UITableViewCell之间添加间距
有什么办法可以增加两者之间的间隔UITableViewCell? 我创建了一个表格,每个单元格只包含一个图像。图像被分配给像这样的单元: cell.imageView.image = [myImages objectAtIndex:indexPath.row]; 但这会使图像放大并适合整个单元格,并且图像之间没有间距。 或者以这种方式说,图像的高度例如为50,我想在图像之间增加20个间距。有什么办法可以做到这一点?

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.