UITextField委托跳转到100%的CPU使用率和使用键盘快捷键时崩溃

所以,我有一个UITextField子类,它是它自己的Delegate ,并在使用键盘快捷方式时崩溃。 它最大限度地在CPU ,并没有给出错误。 没有分配它自己的Delegate ,它没有问题。 当它被指定为Delegate ,即使不使用任何(可选)方法,也会崩溃。 自己尝试一下: 子类UITextField 。 – (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.delegate = self; } return self; } 它应该会崩溃。 编辑回溯: * thread #1: tid = 0x3bb8d, 0x39f14726 libobjc.A.dylib`lookUpImpOrNil + 18, queue = 'com.apple.main-thread, stop reason = signal SIGSTOP frame #0: 0x39f14726 libobjc.A.dylib`lookUpImpOrNil + 18 frame […]

UIWebView占用大量内存

在我的应用程序,当我加载任何网站URL的UIWebView的内存从30MB跳跃到大约140MB。 我正在使用ARC 当解除UIWebViewController [包含UIWebView的Viewcontroller ]时,它不释放内存。 任何机构可以帮助我如何解决这个内存问题,也请给我提供一些ARC内存最佳实践的指针 加载网页: – NSURL *nsurl=[NSURL URLWithString:self.url]; NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl]; [webview loadRequest:nsrequest]; closures视图控制器: – [self dismissViewControllerAnimated:YES completion:^{ webview.delegate=nil; webview=nil; }]; 提前致谢 :)

漫游时CTCarrier mobileNetworkCode是否改变?

CTCarrier的carrierName的文档状态为“如果用户正在漫游,则值不会更改;它始终代表与用户拥有帐户的提供商。” 但是,对于mobileNetworkCode并没有这么说。 这个变化是基于当前的运营商还是保持不变呢? 我正在尝试查找手机是否在startMonitoringSignificantLocationChangescallback中漫游,以避免地理定位。

核心数据关系:如何将新对象插入到实体中,并与另一个实体中的现有对象build立关系

我正在构build一个小的iPhone应用程序,它允许用户保持与朋友一起玩游戏的分数。 我现在需要在核心数据中使用关系,但似乎无法使其工作。 我希望能够将新数据添加到一个实体中,同时创build与另一个实体中现有数据的关系。 我怎样才能做到这一点? 请注意我是Core Data的新手,并且花费了今天最好的一部分来解决这个问题,但运气不佳。 任何帮助将非常感激。 我有3个实体: 分数 , 游戏和玩家 。 分数属性: date , player1Score , player2Score和status 。 游戏属性: title 。 玩家属性: name 。 我有许多关系( 比赛 “—” 游戏 )和( 得分 << — >> 玩家 ) 我已经有了一个游戏和玩家的列表。 用户select哪个游戏和谁在玩,并且利用这个信息,在Scores实体中创build了一组对象,并与所select的游戏和玩家有关系。 这是我的来源: // Scores.h #import <Foundation/Foundation.h> #import <CoreData/CoreData.h> @class Games, Players; @interface Scores : NSManagedObject @property (nonatomic, retain) […]

呈现一个透明的模态UIViewController

我试图自己做一个自定义alertView(对于iOS7 +),但我挣扎alertView演示。 我有一个UIViewController与黑色背景(alpha设置为0.25f),并将alertView作为子视图。 当我想显示alertView时,我以模态方式呈现viewController: -(void) show { UIWindow* window = [[UIApplication sharedApplication] keyWindow]; self.modalTransitionStyle = UIModalPresentationCustom; self.transitioningDelegate = self; [window.rootViewController presentViewController:self animated:YES completion:nil]; } 这是我的animation师对象: -(NSTimeInterval) transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext { NSLog(@"%s",__PRETTY_FUNCTION__); return 2; } -(void) animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext { NSLog(@"%s",__PRETTY_FUNCTION__); UIView* toView = [transitionContext viewForKey:UITransitionContextToViewKey]; toView.alpha = 0; UIView* container = [transitionContext containerView]; [container addSubview:toView]; [UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{ […]

Xcode -dynamic没有指定静态库的错误

我在Xcode中有一个子项目,它创build一个由父项目引用的静态库。 所有这一切都很好,直到iOS 7.1和Xcode 5.1的发布,突然我收到以下警告。 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: -dynamic not specified the following flags are invalid: -ObjC warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/usr/lib/libsqlite3.0.dylib is a dynamic library, not added to the static library 有谁知道我需要做什么来解决这个警告?

在显示新视图之前,iOS会冻结很多秒

在我的应用程序的主视图中,我有一个表视图和两个原型单元格。 我已经使用故事板为每个单元configuration了segues。 在视图控制器中,我将覆盖prepareForSegue将所选单元格上的信息传递到目标视图。 目标视图不是特别复杂,当然也不需要任何繁重的处理来加载。 问题 当我第一次点击主控制器上的一个单元时,目标视图会在5到40秒的长时间延迟后出现。 编辑#2 :后来的水龙头通常更快 注意: 如果在目标视图出现之前再次敲击同一个单元格,则会触发目标视图立即出现。 如上所述,但点击不同的单元格会导致视图立即显示,但会显示来自第一个单元格的数据。 如上所述,但是点击不同的控件(没有关联的段落)会触发目标视图立即出现。 随后的“点击”通常显示较less的延迟。 时间分析器 – 为了我所能看到的 – 显示在这么多秒的延迟期间绝对没有发生任何事情。 我尝试过不同types的赛车,但没有什么区别 一些println显示,发生以下一系列事件: 在主要观点中,prepareForSegue被执行(没有延迟) 那么目标viewDidLoad被执行(没有延迟) …很长时间… 目的地控制器中的集合和表视图开始调用数据源相关的方法来从控制器获取数据。 该视图终于出现(带有不需要的animation,顺便说一句,但这是一个不同的问题) 从我读过的这个话题中,我怀疑这个问题可能与后台线程中发生的一些上述操作有关。 任何想法我可能做错了什么? 编辑#1 :添加了一些代码 在主视图控制器中,使用故事板链接了链接(CTRL-将两个原型单元格拖到目标视图中)。 代码看起来有点像下面这样: override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { var assetIndex = assetsTable.indexPathForSelectedRow()?.row println("prepare for segue – start: \(assets[assetIds[assetIndex!]]!.Name)") if let destination = segue.destinationViewController as? AssetThingsListViewController […]

沿弧线animationUIView

我希望沿着一个圆弧来创build一个视图,如位置1到位置2的图像所示。 实际情况是,视图animation描述了一个完整的圆而不是弧。 我的问题是: 我应该使用CGPathAddArc还是CGPathAddArcToPoint ? 我是否需要使用CGPathMoveToPoint来描述视图的初始位置? 当我遍历代码时,CGPoints值与我所预期的一样,angular度也一样。 我使用下面的函数在一个圆上获取CGPoints CGPoint pointOnCircle(CGPoint centre, float radius, float angle) { float x = centre.x + radius * cosf(angle); float y = centre.y + radius * sinf(angle); return CGPointMake(x, y); } 我正在使用下面的代码和其变体,但至今我还没有设法破解它。 CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; pathAnimation.calculationMode = kCAAnimationPaced; pathAnimation.fillMode = kCAFillModeForwards; pathAnimation.removedOnCompletion = NO; pathAnimation.duration = duration; pathAnimation.repeatCount […]

尝试在Swift 3中保存自定义对象时尝试插入非属性列表对象

我有一个符合NSCoding协议的简单对象。 import Foundation class JobCategory: NSObject, NSCoding { var id: Int var name: String var URLString: String init(id: Int, name: String, URLString: String) { self.id = id self.name = name self.URLString = URLString } // MARK: – NSCoding required init(coder aDecoder: NSCoder) { id = aDecoder.decodeObject(forKey: "id") as? Int ?? aDecoder.decodeInteger(forKey: "id") name = aDecoder.decodeObject(forKey: […]

将date和时间组合成单个NSDate的问题

我想结合一个NSDate的时间值(小时,分钟,秒)与第二个NSDate的date值(日,月,年)与此方法: + (NSDate *)combineDate:(NSDate *)date withTime:(NSDate *)time { NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDateComponents *dateComponents = [gregorian components:(NSDayCalendarUnit | NSWeekdayCalendarUnit) fromDate:date]; NSDateComponents *timeComponents = [gregorian components:(NSDayCalendarUnit | NSWeekdayCalendarUnit) fromDate:time]; NSDateComponents *comp = [NSDateComponents alloc]; [comp setSecond:[timeComponents second]]; [comp setHour:[timeComponents hour]]; [comp setMinute:[timeComponents minute]]; [comp setYear:[dateComponents year]]; [comp setMonth:[dateComponents month]]; [comp setDay:[dateComponents day]]; NSDate *combDate […]