Questions tagged «objective-c»

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

27
UIView 360度无限旋转动画?
我正在尝试旋转UIImageView360度,并在线查看了一些教程。如果没有UIView停止或跳到新的位置,我将无法让他们工作。 我该如何实现? 我尝试过的最新内容是: [UIView animateWithDuration:1.0 delay:0.0 options:0 animations:^{ imageToMove.transform = CGAffineTransformMakeRotation(M_PI); } completion:^(BOOL finished){ NSLog(@"Done!"); }]; 但是,如果我使用2 * pi,它根本不会移动(因为它处于相同位置)。如果我尝试只进行pi(180度),则可以使用,但如果再次调用该方法,则它将向后旋转。 编辑: [UIView animateWithDuration:1.0 delay:0.0 options:0 animations:^{ [UIView setAnimationRepeatCount:HUGE_VALF]; [UIView setAnimationBeginsFromCurrentState:YES]; imageToMove.transform = CGAffineTransformMakeRotation(M_PI); } completion:^(BOOL finished){ NSLog(@"Done!"); }]; 也不起作用。它会升至180度数,暂停片刻,然后重设回0度数,然后再次开始。



13
iOS-从ViewController调用App Delegate方法
我想做的是单击一个按钮(它是用代码创建的),并让它调用另一个视图控制器,然后让它在新的视图控制器中运行一个功能。 我知道可以在IB中相对轻松地完成此操作,但这不是一个选择。 我想做的一个例子是,如果您有两个视图控制器,其中一个带有启动画面。另一个视图控制器在其上进行了遍历,您可以按设置的顺序遍历所有房间。初始屏幕上每个房间都有按钮,可让您跳至遍历中的任何点。

18
如何在iOS上获取设备品牌和型号?
我想知道是否有可能确定当前设备是哪种iPhone(例如)?我知道是否可以通过 NSString *deviceType = [[UIDevice currentDevice] model]; 该模型返回是否拥有“ iPhone”或“ iPod”,但是我想知道是否可以检测/知道我是否拥有iPhone 3GS和iPhone 4。 iPhone 4S (实际上,我真正想做的就是确定我是否拥有3G,因为我正在做大量图形处理工作)。 是的,让我知道,谢谢!
246 ios  objective-c  iphone  ipad 


13
如何比较两个NSDate:哪个是最新的?
我正在尝试实现dropBox同步,并且需要比较两个文件的日期。一个在我的dropBox帐户上,另一个在我的iPhone上。 我提出了以下建议,但是得到了意想不到的结果。我猜比较两个日期时我做的是根本错误的事情。我只是使用了> <运算符,但是我猜这不好,因为我正在比较两个NSDate字符串。开始了: NSLog(@"dB...lastModified: %@", dbObject.lastModifiedDate); NSLog(@"iP...lastModified: %@", [self getDateOfLocalFile:@"NoteBook.txt"]); if ([dbObject lastModifiedDate] < [self getDateOfLocalFile:@"NoteBook.txt"]) { NSLog(@"...db is more up-to-date. Download in progress..."); [self DBdownload:@"NoteBook.txt"]; NSLog(@"Download complete."); } else { NSLog(@"...iP is more up-to-date. Upload in progress..."); [self DBupload:@"NoteBook.txt"]; NSLog(@"Upload complete."); } 这给了我以下(随机和错误)输出: 2011-05-11 14:20:54.413 NotePage[6918:207] dB...lastModified: 2011-05-11 13:18:25 …


30
在Xcode 6中未创建Swift-Objective-C标头
我最近一直在努力将Swift添加到现有项目中,以便以实际的方式进行尝试。 在将Swift源文件添加到项目中后,我对获取“桥接头”(即Objective-C到Swift)没有任何问题。 但是*-Swift.h应该在任何地方都找不到头文件,该头文件公开了Swift类(已标记)@objc或ObjC类的子类: 在我的主要应用程序代码(仍然是Objective-C)中,我看不到任何有关如何完成用Swift编写的新子类的用法的具体说明。 我是首席开发人员的应用程序具有相当大的代码库(70.000行),因此一劳永逸地进行过渡是不可能的。
242 objective-c  xcode  swift 

24
如何使用通过Interface Builder创建的nib文件加载UIView
我正在尝试做一些复杂的事情,但是应该可以做。因此,这对所有您的专家都是一个挑战(本论坛包括很多人:))。 我正在创建一个问卷调查“组件”,我想将其加载到NavigationContoller(my QuestionManagerViewController)上。“组件”是一个“空”组件UIViewController,可以根据需要回答的问题加载不同的视图。 我这样做的方式是: 创建Question1View对象作为UIView子类,并定义some IBOutlets。 创建(使用Interface Builder)Question1View.xib (“我的问题可能在哪里”)。我将UIViewController和都设置UIView为Question1View类。 我将插座与视图的组件链接(使用IB)。 我覆盖了initWithNib我的QuestionManagerViewController,看起来像这样: - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if (self = [super initWithNibName:@"Question1View" bundle:nibBundleOrNil]) { // Custom initialization } return self; } 运行代码时,出现此错误: 2009-05-14 15:05:37.152 iMobiDines [17148:20b] ***由于未捕获的异常' NSInternalInconsistencyException' 终止了应用程序,原因:' -[UIViewController _loadViewFromNibNamed:bundle:]加载了“ Question1View”笔尖,但未设置视图出口。 我敢肯定有一种方法可以使用nib文件加载视图,而无需创建viewController类。



8
卸载应用程序时删除钥匙串项
我正在使用idandersen的scifihifi-iphone代码作为钥匙串并使用以下代码保存密码 [SFHFKeychainUtils storeUsername:@"User" andPassword:@"123" forServiceName:@"TestService" updateExisting:YES error:&error]; 当我从设备上删除应用程序时,密码保留在钥匙串中。 当用户从设备中删除应用程序时,我想从钥匙串中删除密码。我怎样才能做到这一点?

30
设备编译时的Apple Mach-O Linker错误
我刚刚升级到xcode 4.0,无法再部署到iPhone,但遇到Apple Mach-O Linker Error,但它仍然适用于模拟器。 Ld /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Intermediates/iParcel.build/Debug-iphoneos/iParcel.build/Objects-normal/armv7/iParcel normal armv7 cd /Users/yveswheeler/iParcel setenv IPHONEOS_DEPLOYMENT_TARGET 3.2 setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-4.2 -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk -L/Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos -F/Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos -filelist /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Intermediates/iParcel.build/Debug-iphoneos/iParcel.build/Objects-normal/armv7/iParcel.LinkFileList -dead_strip -all_load -ObjC -lxml2 -miphoneos-version-min=3.2 -framework UIKit -framework CoreGraphics -framework QuartzCore /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20.a /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20Core.a /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20Network.a /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20Style.a /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20UI.a /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20UICommon.a /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20UINavigator.a -framework AddressBook -lz.1.2.3 -framework Foundation -framework …

30
体系结构i386的未定义符号:_OBJC_CLASS _ $ _ SKPSMTPMessage“,引用自:错误
我已经导入了用于在后台从应用程序发送电子邮件的框架,即SKPSMTPMessageFramework。有人可以建议为什么显示以下错误 Undefined symbols for architecture i386: "_OBJC_CLASS_$_SKPSMTPMessage", referenced from: objc-class-ref in ConfirmController.o "_kSKPSMTPPartContentTransferEncodingKey", referenced from: -[ConfirmController sendEmail] in ConfirmController.o "_kSKPSMTPPartMessageKey", referenced from: -[ConfirmController sendEmail] in ConfirmController.o "_kSKPSMTPPartContentTypeKey", referenced from: -[ConfirmController sendEmail] in ConfirmController.o ld: symbol(s) not found for architecture i386 collect2: ld returned 1 exit status 框架来源: 锁定MFMailComposeViewController中的字段 更新: 答:只需将文件夹拖放到项目上,然后单击复制。多数民众赞成在选中项目复选框和目标复选框。

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.