iOS 开发过程中遇到的Bug和Warning收录(持续更新)

1.CollectionView的小警告

2015-08-18 16:07:51.523 Example[16070:269647] the behavior of the UICollectionViewFlowLayout is not defined because: 2015-08-18 16:07:51.523

Example[16070:269647] the item width must be less than the width of the UICollectionView minus the section insets left and right values, minus the content insets left and right values.

2015-08-18 16:07:51.524 Example[16070:269647] The relevant UICollectionViewFlowLayout instance is , and it is attached to ; animations = { position=; bounds.origin=; bounds.size=; }; layer = ; contentOffset: {0, 0}; contentSize: {1024, 770}> collection view layout: . 2015-08-18 16:07:51.524 Example[16070:269647]Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.

解决:

Its happens because your collection view cell's width is bigger than collection view width after rotation.suppose that you have a 1024x768 screen and your collection view fills the screen.When your device is landscape,your cell's width will be self.collectionView.frame.size.width - 20 =1004 and its greater than your collection view's width in portrait = 768.The debugger says that "the item width must be less than the width of the UICollectionView minus the section insets left and right values, minus the content insets left and right values".

当你cell的宽度比你collectionView的宽度还要宽的时候,假如你的screen是1024*768的,当你的设备旋转的时候,你的cell宽度将会是大于你的screen宽度768.所有debugger就会告诉你the item width must be less than the width of the UICollectionView minus the section insets left and right values, minus the content insets left and right values,只要把你的collectionView的宽度高度始终保持大于cell的宽度和高度就行了



2.一个tableView的小坑,没注意就掉进去了

2016-07-0510:23:36.776 Taowaitao[1794:40311] *** Assertion failurein -[UITableView _configureCellForDisplay:forIndexPath:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.60.7/UITableView.m:7971

2016-07-0510:24:22.669 Taowaitao[1794:40311] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason:'UITableView (<UITableView: 0x7ffccb0ce600; frame = (0 64; 375 559); autoresize = RM+BM; gestureRecognizers = <NSArray: 0x7ffcc977bbf0>; layer = <CALayer: 0x7ffcc97d0310>; contentOffset: {0, 0}; contentSize: {375, 100}>)failed to obtain a cell from its dataSource (<CategoryViewController: 0x7ffcc94c2fb0>)'

这句话什么意思呢,就是根本加载不到cell好么,我由于要展示不同的cell,切记一定要考虑第一次进来的时候,datasource为0的时候,也是需要加载的,那么一定要跑下面这个方法,不然的话你的cell就是nil的,直接炸了

- (__kindofUITableViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath

解决

Your error suggests that cellForRowAtIndexPath is returning nil for some reason, and I'm guessing it's because you are failing to dequeue a reusable cell. If you want to confirm this, just set a breakpoint after your current dequeue call: I expect you'll find cell is set to nil

当你打断点的时候,如果没有跑上面那个方法,return给datasource代理方法的返回值就是nil的,那么这样就会报错,直接failed to obtain a cell from its dataSouce,切记,一定不能让这个cell为nil


3.跑真机的时候报错(code signing is required for product type 'Application' in SDK 'iOS 9.3')

配置文件出错了

It means you haven't assigned a provisioning profile to the configuration.

Usually it's because "Any iOS SDK" must have a profile and cannot be set to "Don't sign".

All this and more is answered in the TN2250 Tech Note about Code Signing and Troubleshooting.


测试的时候,需要在蒲公英上把需要的真机做一个对应的配置文件,然后更新 Xcode ------> Preferences



这里如果选择AdHoc的时候是以上的配置文件的机器能下载跑程序

这里如果选择Taowaitao Development是真机测试

这里如果选择Distribution是发布用的


4.还是CollectionView的问题,例如你的布局是这样的


那么你在重新reload的时候需要拿出他的高度的话

[cell.collectionView reloadData];
    cell.selectedHeightConstraint.constant = cell.collectionView.collectionViewLayout.collectionViewContentSize.height > 200 ? 200 : cell.collectionView.collectionViewLayout.collectionViewContentSize.height;
    DDLogVerbose(@"点击的当前collectionView的高度是:%lf",cell.selectedHeightConstraint.constant);

这个时候记住一定要先加这句话 不然算出来是不准确的,你用的是375的6s,如果你用5s 4s比375小的话还没事,但是如果你用了6s plus  414的话算出来就坑爹了

cell.collectionView.width =SCREEN_WIDTH;


为了避免计算错误,一定要给真实的宽度给他计算



 
5.AVPlayer监听里面的status的状态一直是failed,根本无法加载出视频,无法加载啊

Error Domain=AVFoundationErrorDomain

Code=-11800

"The operation could not be completed"

UserInfo=0x17423620 {NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x1742d660 "The operation couldn’t be completed. (OSStatus error -12666.)",

NSLocalizedFailureReason=An unknown error occurred (-12666)}


I fail to understand the problem.

I did find a post with the same problem on the foroum, but its unanswered.

Please point me to where I could be going wrong.


6. 正常下的command + R运行没问题,但是用Product -->profile进行调试的时候报错

ld: symbol(s) not found for architecture i386

clang: error: linker command failed with exit code 1 (use -v to see invocation)


解决方法:

先选择这里的 edit scheme

      

然后把release改成debug


然后再进行分析,就OK了

顺便带一下内存泄漏的简单分析

第一步


第二步


第三步(选择里面的 call tree)


第四步(勾上这两个)


第五步(就能看到我们的方法了,点进去就是我们代码内存泄漏的部分)




7. ld: 12 duplicate symbols for architecture x86_64

这种错误真的蛋疼啊,早之前遇到了直接懵逼了

第一种可能就是重复文件名,类名导致的,自己定义了两个同样的东西,或者复制的时候没有把另一个删掉

第二种可能就是在包头文件的时候不相信包进去了.m文件

第三种可能就是自己的类名和方法和系统的重名了,这种肯定编译不过了



8. 对已经的更改的Xib文件再次Run(或者打包的)的时候报报错莫名其妙出现已经删除的控件(缓存也是有坏处的)

然后这个xib文件会被XCode缓存,就是之后,即使在工程里把xib文件删除掉,或者是改变xib文件的某些属性,都

不一定会生效,同样一个xib文件,用不同的名字来调用同样的代码,居然会出两种不同的结果,甚至报错。清

XCode缓存的办法网上介绍说主要有两点,其中第一个点是XCode的菜单里的Product->Clean Build folder...,要

按住option键,这个菜单才会出来,平时只有Clean,也不知道有什么区别。第二点就是模拟器上

的"iOS Simulator"->"Reset Contents and Settings...",搞完这两点,再重新build工程。

至于线上的咋整呢,强制更新,不更新的你来打我呀打我呀......


9. 万年老BUG,iOS 9.0以下的TableView里面的,坑了很久没发现,一出现秒蹦,报错说你没有注册cell

代码是这样的,根本没有觉得有什么问题是吧,简直完美啊!!!

self.tableView.tableFooterView = [UIView new];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.tableView registerNib:[UINib nibWithNibName:reuseIdentifier bundle:nil] forCellReuseIdentifier:reuseIdentifier];
这段代码在iOS 9.0之后完全没问题,但是在9.0以下,就直接会炸
self.tableView.tableFooterView = [UIView new];
就是这句代码导致的,如果顺序就这样写,那么这句代码就会重新跑一遍tableView的代理方法,也就是说当还没有

注册cell的时候去跑tableView的代理,肯定蹦了,根本拿不到cell,就报错说你没有注册cell。

这个问题Apple在iOS 9之后就修复了,这句代码虽然会跑tableView的代理,但是不会跑这个方法(9以下会跑)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

所以你注册或者没注册都没有问题。


记住了:一定要把注册cell的方法写到最前面,避免有些属性刷新的tableView,直接秒



10. UIAlertViewController为什么点击事件的回调那么卡,会delay1秒左右,老的AlertView就没问题,非常快,这个一直不懂为什么

- (IBAction)showAlertView {

    [[[UIAlertView alloc] initWithTitle:@"test" message:@"test" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil] show];
}

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

    NSLog(@"this is fast");
}

-(IBAction)showAlert {

    UIAlertController *controller = [UIAlertController alertControllerWithTitle:@"test" message:@"test" preferredStyle:UIAlertControllerStyleAlert];

    [controller addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

        NSLog(@"this is slow");

    }]];

    [self presentViewController:controller animated:NO completion:nil];

}

11. iOS 10上的BUG,UITextField在密文输入情况下的BUG这个真的坑了我一下午,终于找到原因了


如果你的正常大小和minFontSize一样的就不会,如果不同,在iOS10上面输入到和TextField一样宽的时候直接程序卡主,死了我目前是把两者弄成一样了




12. iOS 9以下的BUG Xib子类关联问题(特殊情况)

如图



问题来了,其他类如果你用的是自定义的子类,你如果没有在右边写上子类,那么你直接写代码就会蹦。

但是这是个奇葩,当你关联SZTextView的时候,你没有写子类,右边显示的是灰色的UITextView,

在iOS 9以上的系统跑是没问题的,在iOS 9以下的系统就会蹦,这应该是Xcode 的BUG了,父类怎么可能找到子类

的方法呢???!!!这你妹坑的一B,也怪我没有注意细节,调试的时候删掉了


13. iOS UISearchBar 不自动弹键盘的原因(进去和pop回来)

都是

这里需要主要的是,我搜索界面是UISearController做的,当我进去的时候要自动进入搜索状态


我直接在viewdidload里面调用

[self.searchControllersetActive:YES];

 [self.searchController.searchBarbecomeFirstResponder];

都没用,这里你一定要实现UISearchController的代理

- (void)didPresentSearchController:(UISearchController *)searchController
{
    DDLogVerbose(@"已经弹出需要的页面");
    [searchController.searchBar becomeFirstResponder];
}

这样的话键盘和蒙层都弹起来了,完美!!!



但是当咱们pop回来的时候呢,我这么玩根本不弹键盘



而且我pop回来的时候把动画改为NO,连动都不动一下了,也就是根本不会有向上拉的动作了,那么我的解决方案是

- (void)viewDidAppear:(BOOL)animated
{
    
    if (self.count > 0)
    {
        DDLogVerbose(@"viewwillAppear......");
        [self.searchController setActive:YES];
        [self.searchController.searchBar becomeFirstResponder];
        self.searchController.searchBar.text = self.pushKeywords;
    }
}
切记:

如果你pop有动画和没动画都有的情况,那么建议你直接写在DidAppear的方法里面,这样就能保证向上的拉起动作和键盘都能Active,不然当你pop No 动画的时候,是不会有键盘弹起来的!!!

完美结局的效果如下




14. iOS 8.1-8.3之间富文本不显示删除线

由于你的富文本被切断了,第一段也要设置,不然在8.1-8.3上是没有删除线的

{NSUnderlineStyleAttributeName: @(NSUnderlineStyleNone)}

NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] init];
 [attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:@"test "
                                                                          attributes:@{NSUnderlineStyleAttributeName: @(NSUnderlineStyleNone)}]];
 [attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:@"s"
                                                                         attributes:@{NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle),
                                                                                      NSBackgroundColorAttributeName: [UIColor clearColor]}]];
 [attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:@"tring"]];



15. ld:library not found for -lopencore-amrnb

这个是什么造成的呢?我这里IM用的是融云,同事更新了文件,我在update之后直接报错,根本无法运行。根据提示

可以看出,说找不到文件,但是人家就是上传了啊,然后打开我们的SVN,下图是同事svn文件列表



可以看到室友这个.a文件的,但是我的svn里面就是找不到这个文件,关键是手动添加都加不进来,这时候再看这个图,可以判断是cornerstorn的问题,肯定被过滤了



解决方法1 :就是删除.a这个限制,就能正常上传下载了


解决方法2:从同事那里copy过来,放进自己本地文件夹里面就可以了


点击打开链接

这里有个大神介绍静态库和framework,需要了解的可以看下,这个BUG记录下,着实有点坑人


16. CGFLoat怪异的初始化值的问题

    CGFloat price;
    NSLog(@"%f",price);

正常状态下的打印肯定是0没有错的,而且模拟器上release和debug两个环境打印的都是0,关键是直接Xcode跑程序到真机上打印的也是0,最恶心的是release的时候,adhoc包安装到手机上时,你打印就不是0了,竟然是个随机数,stack上分配给price的内存可能是有值的,所以切记在初始化的重要性啊

In C you need to initialize local variables. The value you're seeing is a garbage value, depending on various factors.




  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
iOS扑克牌游戏的开发过程需要经历以下几个步骤。 首先,确定游戏的需求和功能。开发过程开始前,我们需要明确游戏类型、玩法和目标用户等方面的需求。比如,我们可以设计一个经典的扑克牌游戏,可以选择玩家与电脑对战或多人在线对战等不同玩法。 其次,进行界面设计。界面设计是游戏开发的关键步骤之一,包括游戏界面的布局、色彩搭配、按钮和卡牌图标等的设计。在设计界面时,需要考虑用户体验,使界面简洁易用、美观大方。 然后,进行编码和程序开发。在开发过程,我们可以使用Objective-C或Swift等编程语言进行开发开发过程,需要编写代码实现游戏逻辑,比如洗牌、发牌、计分等功能。同时也要确保游戏的流畅性和稳定性。 接下来,进行测试和优化。游戏开发完成后,需要进行测试,检查是否存在bug和逻辑错误,并及时修复。同时,还要通过不同设备和系统的测试,确保游戏在不同平台的表现一致性。 最后,发布游戏。当游戏经过充分测试后,我们可以将其提交到苹果App Store进行审核发布。在发布前需要准备相关的应用截图、描述文案以及适配不同设备的设置。 综上所述,iOS扑克牌游戏的开发过程包括确定需求、界面设计、编码和程序开发、测试和优化以及发布等多个环节。通过这个过程,我们可以开发出一款具有良好用户体验和稳定性的扑克牌游戏。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值