Tag: cocoa触摸

一次加载一个图像

所以这个代码基本上从服务器获取数据,创build一个图像,然后将其添加到视图。 不过,我希望一次更新一个视图。 现在,所有图像加载完毕后,所有的图像都立即更新。 我想更新视图,每次上传一个新的图像 – 这应该发生在addImage方法中,而是等待所有的图像加载。 我试着用dispatch_async来解决这个问题,但是没有成功。 那么我怎样一次加载一张图片? AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { //some code not displayed here that parses the JSON for (NSDictionary *image in images){ if ([[image objectForKey:@"ContentType"] isEqualToString:@"image/png"]){ NSString *imgLink = [[image objectForKey:@"MediaUrl"] JSONStringWithOptions:JKSerializeOptionPretty includeQuotes:NO error:nil]; NSURL *url = [NSURL URLWithString:path]; NSData *data = [NSData […]

Swift – 线程1:信号SIGABRT

我试图让一个视图控制器更改视图,当一个button被点击,但我不断收到一个错误说: 线程1:信号SIGABRT 我想以编程方式完成一切,而不是使用Xcode中的Storyboard。 我将在下面提供我的代码。 顺便说一下,我正在使用Swift。 AppDelegate.swift import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. self.window = UIWindow(frame:UIScreen.mainScreen().bounds) let navController = UINavigationController() let mainViewController = ViewController(nibName:nil, bundle:nil) // NavigationBar/Title colour navController.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.whiteColor()] UINavigationBar.appearance().barTintColor = […]

拉伸的形状,以适应框架?

我有一个应用程序,我正在绘制一个特殊的椭圆,我做了一系列的贝塞尔path如下: CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSaveGState(context); CGMutablePathRef pPath_0 = CGPathCreateMutable(); CGPathMoveToPoint(pPath_0, NULL, 515.98,258.24); CGPathAddCurveToPoint(pPath_0, NULL, 515.98,435.61,415.54,515.98,258.24,515.98); CGPathAddCurveToPoint(pPath_0, NULL, 100.94,515.98,0.50,435.61,0.50,258.24); CGPathAddCurveToPoint(pPath_0, NULL, 0.50,80.86,100.94,0.50,258.24,0.50); CGPathAddCurveToPoint(pPath_0, NULL, 415.54,0.50,515.98,80.86,515.98,258.24); CGPathCloseSubpath(pPath_0); CGContextSetRGBFillColor(context, 1.0000, 1.0000, 1.0000, 1.0000); CGContextSetRGBStrokeColor(context,0.0000,0.0000,0.0000,1.0000); CGContextSetLineWidth(context, 1); CGContextSetMiterLimit(context, 10.0000); CGContextAddPath(context, pPath_0); CGContextDrawPath(context, kCGPathFillStroke); CGPathRelease(pPath_0); CGContextRestoreGState(context); 我想知道,在核心graphics中,有没有什么方法可以把我刚刚创build的形状横向和纵向拉伸,使其完全符合其视图框架? IE浏览器,所以我不必手动进入我所有的观点和价值观,并写在视图边界? 我知道这种形状不会那么困难,但我有一些更复杂的形状,更费时间,我宁愿避免这样做。

UIView是否保留其视图控制器?

一个UIView保留它的关联视图控制器? 例如,在以下代码中,视图由父视图保留。 如果这个视图也保留了它的ViewController,那么我可以继续在loadView方法中释放控制器。 – (void) loadView { … MyViewController* ctrl = [[MyViewController alloc] init]; [self.view addSubview: ctrl.view]; [ctrl release]; } 我想,另一种方法是跟踪控制器作为实例variables,并在适当的时候释放它。 谢谢

从视图控制器引用模型的方法

到目前为止,我所见过的所有例子(包括斯坦福播客)都通过声明它作为视图控制器的一个属性并使用它来使用它: #import "myClass.h" // assume it carries a single NSString property @interface @property (nonatomic,strong) myClass *myobject; @end @implementation ViewController -(void)viewDidLoad { self.myObject = [[myClass alloc] init] . . . -(void)someMethod{ displayLabel = self.myObject.myString; 似乎比MVC更自我.CV。 在混淆了我自己的这个作品之后: #import "myClass.h" @implementation ViewController { MyClass *myObject; } -(void)viewDidLoad { myObject = [[myClass alloc] init] } . . . -(void)someMethod{ […]

应用程序未在设备设置 – >通知iOS 7中列出

我正在注册Apple推送通知,并注意到我的应用程序未在设备设置 – >通知iOS 7中列出。不过,我可以在iOS 6中看到这一点。 此外,我一直在接收iOS 7的推送通知,所以我正确地从APNS获取令牌。 任何线索可能是错误的iOS 7。

二进制searchNSArray没有对象search,但条件

所以,我有这个NSNumber对象的数组。 我有一些我自己的,我需要在数组中find一个数字比我的数字最小的余量。 我如何使用二进制search? 方法: indexOfObject:inSortedRange:options:usingComparator接受对象作为参数,我没有它。 如何使用这种条件进行二分查找,但没有对象?

坚实的解决scheme,以基于子视图灵活调整UIView的大小

想象一下,你有四个左右的意见,所有宽度100,不同的高度。 你有一个包装所有的包装视图W. A | B | W C | D | 小视图的高度可以改变。 那时候你想要他们全部移动,适当地浮动,并resizeW. 现在,我正要写几行代码来做到这一点。 所以..(1)你会find所有的子视图,并从上到下依次列出。 那么(2)每次有变化,你都要(3)重新定位每个ABCD。 每一个的位置是它上面项目的高度的总和,(4)将W调整到所有高度的总和。 现在,这一切都好,但白痴重新发明轮子! 我在iOS中缺less明显的东西吗? 是不是每个人都用这个包来做呢? 还是内置的东西? 情况如何? (请注意,当然,对于我们的Android朋友来说,这是内置的!当然,任何web-html系统都会自动完成此操作。) iOS视图的正确工程解决scheme是什么? logging这只是iOS7 +,没有老式的东西需要被覆盖,如果它有所作为。 干杯

如何使用文档目录中的声音文件作为本地通知?

在我的iOS应用程序中,如何播放存储在应用程序文档目录中的声音文件作为本地通知,而不是应用程序包内的声音文件? 我已经看到了App Store上的一些应用程序做这个,我想知道这是如何可能的。

获取一个UILocalNotification每周开火

我已经设置了一个本地通知来触发。 我想知道如何让它在每周的同一时间,例如周一上午9点​​重复。 这是我的代码到目前为止: @IBAction func scheduleLocal(sender: UIButton) { guard let settings = UIApplication.sharedApplication().currentUserNotificationSettings() else { return } if settings.types == .None { let ac = UIAlertController(title: "Cant Schedule", message: "No Permission", preferredStyle: .Alert) ac.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil)) presentViewController(ac, animated: true, completion: nil) return } let notification = UILocalNotification() notification.fireDate = NSDate() notification.alertBody = […]