Home  >  Article  >  Backend Development  >  iOS development questions (5)

iOS development questions (5)

黄舟
黄舟Original
2017-01-20 09:34:331272browse

42. Warning: Multiplebuild commands for output file
The target references a resource with a duplicate name
Find the current target, expand it, find the CopyBundle Resources column, and then find the resource with the duplicate name in it and delete the unnecessary ones That's it
43. Signature error: Provisioningprofile can't be found
In Xcode, when you update your certificate and then recompile your program, Code Sign error: Provisioning will always appear during real-machine debugging. profile 'XXXX' can't be found will annoy you. Let’s talk about the solution below so that you can solve this problem well.
1. Close your project, find the project file XXXX.xcodeproj, right-click on the file and select "ShowPackage Contents". A new Finder will open. Note: In fact, XXXX.xcodeproj is a folder. The three files in the newly opened Finder here are the files in the XXXX.xcodeproj folder.
2. Find project.pbxproj in the newly opened Finder and open it. Find the encoding information for your previous certificate here. The error message I reported before was:
CodeSign error: Provisioning profile '37D44E7F-0339-4277-9A82-C146A944CD46', so I used the search method to find all the lines including 37D44E7F-0339-4277-9A82-C146A944CD46. and delete.
3. Save, restart your project, and compile again. That's OK.
44. Arc4random_uniform is unavailable after upgrading to Xcode 4.6
When the project is upgraded to Xcode4.6, a compilation error occurs:

Useof undeclared identifier 'arc4random_uniform'; did you mean 'arc4random_stir'?

It seems that SDK 6.1 does not support 'arc4random_uniform', change The problem is solved after changing to 'arc4random'.
45. After upgrading Xcode4.6, a compilation error occurred: Undefinedsymbols for architecture x86_64: "_OBJC_CLASS_$_NSMutableOrderedSet"
In the build settings, set "Implicitly link Objective-C Runtime Support" to NO, and the problem is solved.
46. After upgrading Xcode4.6, a warning appeared: function'sleep' is invalid in C99
#import and then solved. After upgrading to Xcode4.6, many header files are not automatically imported by default, such as stdlib.h and unistd.h.
47. Compilation error: autolayout on ios versions prior to 6.0
This problem occurs when compiling Target 4.0 app in Xcode 4.6 (real machine debugging, device is 3GS, upgraded to iOS 6.1.3). Find the .xib file that reported the error, and disable "UseAutolayout" (see the figure below) in the Document panel.

48. How to set the text alignment of the button TitleLabel?
Set the contentHorizontalAlignment property:
emailBtn.contentHorizontalAlignment= UIControlContentHorizontalAlignmentLeft;
Or use contentEdgeInset to adjust the text margins (0 means not aligned):
emailBtn.contentEdgeInsets= UIEdgeInsetsMake(0, 10, 0, 0) ;
Or use both together.
49. Error: errorDomain=UA_ASIHTTPRequestErrorDomain Code=8 "Failed to move file from
Theerror happens after the file is downloaded; but before the file is successfully moved from the tmp location to the Cache location
The error happens after The file is downloaded to a temporary file, but before it is moved to the documents directory (you can use iExplorer to check the existence of the temporary file).
Use "[requestsetShouldAttemptPersistentConnection:NO];" to solve this problem. 50. Compilation error: "has been modified since the precompiled header was built"

The file was modified when precompiling the header.
51. Error Could not change excutable permissions on the application
Cannot be used. Installing two different applications with the same AppID on the iPhone usually causes problems when executing the Project-->Profile command in Xcode. This is because a debug application is usually installed on the iPhone during real-device debugging and the Project-- is executed. >Profile and then install the program again on the iPhone. The AppIDs of the two programs are naturally the same, so the above error occurs. Solution: First delete the program on the iPhone, and then execute the Project-->Profile command.

52. Instruments error: Targetfaild to run, as shown in the figure below.

iOS development questions (5)##



点击菜单栏Scheme 的左下角,选择“Edit Scheme...”,在弹出窗口左侧边栏选中“Profile xxx.app”,将其“BuildConfiguration”从“Release”修改为 “Debug”。
53、查看指针所指向的对象
如果知道地址,可以用GDB命令打印该地址所代表的对象,例如:
po 0x1fba2e20
如果该指针不是一个对象,用:
p0x1fba2e20
54、Xcode 打包时 skip install的问题
总结:在自身工程里面需要将skipinstall 设置为NO, 在引入其他静态库文件的工程中skip install 设置为YES,否则在 Orgnizer 中无法发布你的程序。
-主App是需要部署的,所以不要将Skip Install设为YES, 只需要改依赖项目。
55、错误: Pushinga navigation controller is not supported 
SDK不允许直接在一个 NavigationController 中 push 一个 NavigationController。你可以用这句代码代替:
[self.navigationControllerpushViewController:nc.topViewController animated:YES];
56、为什么当用户点击Tab bar 上的按钮,总是会显示所选 NavigationController 的 rootViewController?
你可以为TabBarController 指定一个delegate 属性,并在 delegate 对象中实现 UITabBarControllerDelegate 委托:

#pragma mark TabBarController Delegate
- (BOOL)tabBarController:(UITabBarController *)tabBarControllershouldSelectViewController:(UIViewController *)viewController {
UIViewController *tbSelectedController= tabBarController.selectedViewController;
if ([tbSelectedController isEqual:viewController]) {
return NO;
}
return YES;
}

57、使用setTitle 不能刷新 NavigationBar 的标题文本
有时候使用ViewController的 setTitle 方法并不能刷新 NavigationBar 的 title文本。极大的可能是你使用类似的代码定制了 titleView:

UILabel* label = [[[UILabel alloc] init] autorelease];
label.backgroundColor=[UIColor clearColor];
label.text = self.title;
label.font = [UIFont systemFontOfSize: 20];
……
[self.navigationItem setTitleView: label];

如果这样,你需要用同样的代码重新定制titleView,才能刷新 NavigationBar title。或者,使用默认的 TitleView 而不要去定制它。
58、 nested push animation can result in corrupted navigation bar……
如果你在代码中连续多次(两次以上)pushViewController,会出现以上信息,这既不是错误也不少警告,只是控制台输出的信息,但它会导致一些潜在的问题,比如NavigationController 的栈错误(比如用户有时候必须连按两次 backButton 才能返回上级视图)。往往还会伴随有如下信息的输出:
Unbalancedcalls to begin/end appearance transitions
所谓连续多次,是指至少有一次push 是不经过用户交互而直接代码调用的。例如,当用户点击一个 TableViewCell,弹出一个 ViewController,然后在这个ViewController 的 viewDidLoad 方法或 viewWillAppear 方法中用代码 Push 另一个 ViewController。这第二次push 并不是由用户动作而是由代码触发的,因此会导致上述问题。
解决办法是,在第二次push 时,将 animated 参数设置为 NO。
59、真机可以执行,模拟器不行
有时候出现模拟器不能调试的情况,程序一运行就退出,而且模拟器似乎“卡死”掉了,只出现一个黑黑的窗口,按Home键也没有作用。但是在真机上程序却可以运行。这个问题的原因未知,但有一个解决方式是:在另一个工程中打开模拟器,然后在模拟器中把有问题的程序删除即可。
60、警告“numeration not handledin switch”
新的Apple LLVM compiler 4.0中,会对 switch 变量进行检查,如果该变量为枚举类型,则需要处理所有的枚举值,你可以添加一个 default:break;语句表示所有未列举的枚举值已处理。或者将编译选项"Check switch statements"设置为NO。也可以用下列宏忽略switch 检查:

#pragmaclang diagnostic push
#pragmaclang diagnostic ignored "-Wswitch"......
#pragmaclang diagnostic pop


以上就是iOS 开发百问(5)的内容,更多相关内容请关注PHP中文网(www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]