Tag: objective c

将longpress手势和拖动手势组合在一起

我正在转移我的观点 UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(moveRight:)]; [panRecognizer setMinimumNumberOfTouches:1]; [panRecognizer setMaximumNumberOfTouches:1]; [panRecognizer setDelegate:self]; [bubbleView[rightCnt] addGestureRecognizer:panRecognizer]; [panRecognizer release]; 现在,我想通过长按拖动来做同样的事情。 任何想法?

使用NSPredicate来确定一个string是否等于另一个string

我有[CalCalendarStore eventPredicateWithStartDate]方法返回的CalEvents的NSArray 。 从返回的事件中,我试图只保留事件标题== @"on call" (不区分大小写)。 我可以使用下面的代码(其中“events”是一个用CalEvents填充的“NSArray”)保存标题包含 @"on call"的事件: NSPredicate *onCallPredicate = [NSPredicate predicateWithFormat:@"(SELF.title CONTAINS[c] 'on call')"]; [events filteredArrayUsingPredicate:onCallPredicate]; 我已经尝试使用谓词格式string,如: @"SELF.title == 'on call'"但这似乎不工作。 有没有更简单的方法来做到这一点?

我如何将NSDictionary转换为NSMutableDictionary?

我有一个现有的NSDictionary有: { "charts_count" = 2; "created_at" = "2010-04-12T16:37:32Z"; exchange = NASDAQ; "followers_count" = 259; id = 8404; industry = "<null>"; "messages_count" = 1436; ric = "GRPN.O"; sector = "<null>"; symbol = GRPN; title = Groupon; "updated_at" = "2011-09-05T04:17:56Z"; } 我怎样才能把这些内容,并把它放到一个新的NSMutableDictionary?

弱自引用的generics

我试图找出一种方法来使用typeof来创build一个self的弱引用在块中使用,以避免保留周期。 当我第一次读到这个时,似乎这个惯例是使用__block typeof(self) bself = self; ,编译但使用__block来避免保留周期不再工作,应该使用__weak 。 然而__weak typeof(self) bself = self; 导致错误: 'typeof(self)'(aka'TUAccountsViewController * const __strong')types已经有保留属性设置 有没有办法使用typeof或其他调用一般创build一个self弱引用?

架构i386的未定义符号:“_SCNetworkReachabilitySetCallback”

我使用xcode4,在一个openglES项目上,我已经添加了从应用程序购买代码从教程: http ://www.raywenderlich.com/2797/introduction-to-in-app-purchases 我已经添加了SystemConfiguration.framework但发生此错误: Ld /Users/Eros/Library/Developer/Xcode/DerivedData/blatest-acmdklrqungznggpjewgxuxqsvwo/Build/Products/Debug-iphonesimulator/blatest.app/blatest normal i386 cd /Users/Eros/Desktop/blatestDB setenv MACOSX_DEPLOYMENT_TARGET 10.6 setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk -L/Users/Eros/Library/Developer/Xcode/DerivedData/blatest-acmdklrqungznggpjewgxuxqsvwo/Build/Products/Debug-iphonesimulator -F/Users/Eros/Library/Developer/Xcode/DerivedData/blatest-acmdklrqungznggpjewgxuxqsvwo/Build/Products/Debug-iphonesimulator -F/Users/Eros/Desktop/blatestDB -filelist /Users/Eros/Library/Developer/Xcode/DerivedData/blatest-acmdklrqungznggpjewgxuxqsvwo/Build/Intermediates/blatest.build/Debug-iphonesimulator/SLQTSOR.build/Objects-normal/i386/blatest.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -framework Foundation -framework UIKit -framework OpenGLES -framework QuartzCore -framework AVFoundation -framework AudioToolbox -framework CoreAudio -framework CoreGraphics -framework OpenAL -lz -framework MediaPlayer -framework AVFoundation -framework […]

使用Objective C / Cocoa来避开unicode字符,即\ u1234

我从中获取数据的某些站点正在返回UTF-8string,并且UTF-8字符被转义,即: \u5404\u500b\u90fd 有一个内置的cocoafunction,可能有助于这一点,或者我将不得不写我自己的解码algorithm。

UIBezierPath减去path

通过使用[UIBezierPath bezierPathWithRoundedRect:byRoundingCorners:cornerRadii:] ,我可以创build一个四舍五入的视图,如: 我怎么能从这个(或其他方式)减去另一条path,来创build一个这样的path: 有什么办法可以做这样的事吗? 伪代码: UIBezierPath *bigMaskPath = [UIBezierPath bezierPathWithRoundedRect:bigView.bounds byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight) cornerRadii:CGSizeMake(18, 18)]; UIBezierPath *smallMaskPath = [UIBezierPath bezierPathWithRoundedRect:smalLView.bounds byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight) cornerRadii:CGSizeMake(18, 18)]; UIBezierPath *finalPath = [UIBezierPath pathBySubtractingPath:smallMaskPath fromPath:bigMaskPath];

保存NSArray到NSUserDefaults并获取它在NSMutableArray中

我如何保存在NSUserDefaults NSArray ,然后将其加载回NSMutableArray来填充UIPickerView ? 此外,问题是新值将被添加到该NSMutableArray ,然后该数组将被转换为NSArray被保存在NSUserDefaults (因为NSMutableArray无法保存在NSUserDefaults )。 任何帮助赞赏.. 谢谢

iOS框架更改一个属性(例如宽度)

这个问题最初被要求用于Objective-C编程语言。 在写作的时候,斯威夫特还没有存在。 题 是否有可能只改变CGRect 一个属性? 例如: self.frame.size.width = 50; 代替 self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width, 50); 当然我明白, self.frame.size.width是只读,所以我想知道如何做到这一点? CSS ANALOGY需要 您自担风险 对于那些熟悉CSS ,这个想法与使用非常类似: margin-left: 2px; 而不必改变整个价值: margin: 5px 5px 5px 2px;

从NSDate的date名称?

我想在我的iPhone应用程序中显示一天的名字,我没有find解决scheme。 感谢帮助