iOS 开发百问(8)

黄舟
Release: 2023-03-05 06:44:02
Original
1114 people have browsed it

90、找不到 Profile 错误“CodeSign error: no provisioning profile at path '/Users/yourname/Library/MobileDevice/ProvisioningProfiles/F87A055A-EC0D-4F19-A015-57AB09DEBECB.mobileprovision'”
在 ProjectNavigator 中选择你的项目,使用 View ->Version Editor -> Show Version Editor(或者使用工具栏上的“439.jpg
”按钮)。在当前版本(即 左边的文本窗格)中编辑,搜索“F87A055A-EC0D-4F19-A015-57AB09DEBECB”字串,然后将所有的“"PROVISIONING_PROFILE[sdk=iphoneos*]" ="F87A055A-EC0D-4F19-A015-57AB09DEBECB";”行删除。
91、iOS 7 中,导航栏重叠在 ViewController 的 view 之上(即 view 上移了 44 像素)
将导航控制器的 Top Bar 设置为一种“Opacque ...”(不透明)类型。
92、为什么导航栏的righBarButtonItems 显示的排列顺序跟它们加入时的相反?
rightBarButtonItems 中的 item 在加入时是从右向左加入的。
假设我们这样加入3个按钮到 rightBarButtonItems 中:
[self.navigationItem setRightBarButtonItems:@[b1,b2,b3]animated:NO]; 则你看到的3个按钮排列顺序为:b3,b2,b1。
93、为什么有时候用 OTA 方式安装程序后会多出一个“正在安装...”图标,并无法删除该图标?
该问题只在 iOS 7 下存在。如下图所示:


440.jpg

其中,“网络助手”是程序安装完出现在桌面上的图标,“正在安装...”是安装过程中显示的图标,这个图标在安装完成后仍然存在,并且用户无法删除。
这是由于安装是的描述文件( .plist 文件)和 .ipa 文件中的 bunndle id 不一致导致的。解决办法,修改项目的Bundle ID为 .plist 文件中的Bundle ID,编译出新的 .ipa 文件,然后重新在设备上安装此 .ipa 文件。此时“正在安装...”图标即可删除。
94、无意中修改了 SDK 的头文件,Xcode报告“'xxx.h' hasbeen modified since the precompiled header was built”
Clean,仍然无法编译,在关闭 Xcode 时,Xcode 提示文件不存在,无法自动保存,并不允许退出。使用“强制退出...”关闭 Xcode,Clean,重新编译成功。
95、iOS 7.1下in-house发布无法安装 app,报告“Could not load non-https manifest URL”
将部署所使用的 manifest.plist文件放到 https 服务器上,并且将 manifest URL 由原来的 http 地址改为 https 地址。
96、如何让 UIButton 的 image 位于 title 的右边?
默认情况下 UIButton 的 image 位于 title 左边:
441.jpg
但有时候你可能希望是这样的:
442.jpg
则需要使用到setImageEdgeInsets 方法:

float width = _button.bounds.size.width;
[_buttonsetImageEdgeInsets:UIEdgeInsetsMake(0, width-_button.imageView.bounds.size.width,0, 0)];
[_buttonsetTitleEdgeInsets:UIEdgeInsetsMake(0, -_button.imageView.bounds.size.width+5,0, 0)];
Copy after login

97、修改table view的 section header 样式
请使用UITableViewDelegate 中的 willDisplayHeaderView方法。

- (void)tableView:(UITableView *)tableViewwillDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
{
if([viewisKindOfClass:[UITableViewHeaderFooterView class]]){
UITableViewHeaderFooterView *tableViewHeaderFooterView =(UITableViewHeaderFooterView *) view;
tableViewHeaderFooterView.contentView.backgroundColor = [UIColorclearColor];
tableViewHeaderFooterView.textLabel.font=[UIFont systemFontOfSize:13];
tableViewHeaderFooterView.textLabel.textColor=[UIColor blackColor];
}
}
Copy after login

98、定制 search bar的背景色

for (UIView *subview in self.searchBar.subviews)
{
if([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")])
{
[subview removeFromSuperview];
break;
}
}
self.searchBar.backgroundColor = [UIColor colorWithWhite:0.85 alpha:1];
Copy after login

99、Autolayout 下 UIScrollView 不会滚动
只有当 UIScrollView 的 ContentSize 大于 UIScrollView 的 frame 大小,UIScrollView 才可滚动。
但由于 constraints 的影响, 设置 ContentSize 往往无效,因此UIScrollView不可滚动。我们可以实现 viewDidLayoutSubviews 方法,在该方法中设置 ContentSize :

- (void)viewDidLayoutSubviews {
_scrollView.contentSize=CGSizeMake(_scrollView.frame.size.width,_scrollView.frame.size.height+60);
}
Copy after login

100、在头文件中出现某个type“Unknown type name”
其实该 type 所在的框架或库已被引用。例如出现错误“Unknown type name CGPoint”,而 CGPoint 所在的框架 CoreGraphics 已被项目正确引用了。
这种错误是由于“交叉头文件引用”导致的。典型的错误是,一个头文件(例如 a.h)在 .pch 文件中包含了。而 .pch 文件在编译任何 .m 文件中都会自动被包含。 因此如果要在 .pch 文件中包含 a.h 文件,正确的做法是用 #ifdef__OBJC__ 宏:

#ifdef __OBJC__
#import "a.h"
#endif
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!