在本文中,我们将为您详细介绍tableView中的Swift第一个单元格丢失了,因为添加了UISearchController的相关知识,并且为您解答关于swiftui列表的疑问,此外,我们还会提供一
在本文中,我们将为您详细介绍tableView 中的 Swift 第一个单元格丢失了,因为添加了 UISearchController的相关知识,并且为您解答关于swiftui 列表的疑问,此外,我们还会提供一些关于Apple Pay 按钮的设计不正确,因为添加了“Apple Pay”、iOS Swift 应用程序随机 EXC_BAD_ACCESS 崩溃:swift_bridgeObjectRetain swift_retain swift::RefCounts
- tableView 中的 Swift 第一个单元格丢失了,因为添加了 UISearchController(swiftui 列表)
- Apple Pay 按钮的设计不正确,因为添加了“Apple Pay”
- iOS Swift 应用程序随机 EXC_BAD_ACCESS 崩溃:swift_bridgeObjectRetain swift_retain swift::RefCounts
- iOS TableView reloadData 刷新列表 cell 乱跳、tableview 闪动的问题。
- ios UISearchController
tableView 中的 Swift 第一个单元格丢失了,因为添加了 UISearchController(swiftui 列表)
如何解决tableView 中的 Swift 第一个单元格丢失了,因为添加了 UISearchController
从其他页面推送导航后,表格视图中的第一个单元格丢失。为什么 tableview 不滚动到顶部位置。
代码 https://github.com/frankenly/ios-tableview-search-lost
https://github.com/frankenly/ios-tableview-search-lost/blob/main/StackOverflow/StackOverflow/ViewController.swift
解决方法
首先你可以做一件事
- 如图所示在 tableview 单元格上方添加搜索栏
您可以添加以下方法
let indexPath = IndexPath(row: 0,section: 0)
self.tableView.scrollToRow(at: indexPath,at: .top,animated: true)
希望它对你有用。谢谢。
Apple Pay 按钮的设计不正确,因为添加了“Apple Pay”
如何解决Apple Pay 按钮的设计不正确,因为添加了“Apple Pay”
我正在尝试获得 Apple 对我的应用的批准。我不知道该怎么做。这是他们返回的表明问题的图像
他们提到的问题是
您的应用程序使用 Apple Pay 作为购买机制,但没有像 Apple Pay 人机界面指南中描述的那样恰当地使用 Apple Pay 品牌和用户界面元素。具体:
- Apple Pay 按钮的设计不正确,因为添加了“Apple Pay”。
实际使用什么?谢谢。
解决方法
您需要遵循 Apple 的“Apple Pay”指南,而该设计不是其中之一。我建议遵循官方文档:
https://developer.apple.com/design/human-interface-guidelines/apple-pay/overview/buttons-and-marks/
按照您当前的设计,您应该使用“白色”变体:
您的文字可以是“Pay with {apple icon}Pay”。从尺寸和形状来看:
默认的cornerRadius 为4 点、0 点或完全圆角。最小高度为 30 磅,最小宽度为 100 磅(不含额外文字)或 140 磅(含额外文字)。
iOS Swift 应用程序随机 EXC_BAD_ACCESS 崩溃:swift_bridgeObjectRetain swift_retain swift::RefCounts
如何解决iOS Swift 应用程序随机 EXC_BAD_ACCESS 崩溃:swift_bridgeObjectRetain swift_retain swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1>
我不断收到来自随机用户的随机崩溃报告。不幸的是,我无法定期重现这一点。用户说崩溃是在 discussionViewController
中随机发生的。所有崩溃报告都有类似的内容:
0 libswiftCore.dylib 0x00000001a53face4 swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::incrementSlow(swift::RefCountBitsT<(swift::RefCountInlinedness)1>,unsigned int) + 60 (atomic:1003)
1 libswiftCore.dylib 0x00000001a53c59e0 swift_retain + 124 (RefCount.h:813)
2 libswiftCore.dylib 0x00000001a5401d60 swift_bridgeObjectRetain + 56 (SwiftObject.mm:585)
3 APPNAME 0x0000000102b59734 closure #1 in discussionViewController.fetchPostData() + 7916
这是完整的崩溃日志和崩溃的线程:
Hardware Model: iphone11,6
Process: APPNAME [11770]
Path: /private/var/containers/Bundle/Application/.../APPNAME.app/APPNAME
Identifier: ----
Version: 62 (62)
AppStoretools: 12E262
AppVariant: 1:iphone11,6:13
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: ---- [1824]
Date/Time: 2021-06-17 12:07:01.4346 +1000
Launch Time: 2021-06-17 12:06:56.4993 +1000
OS Version: iPhone OS 14.6 (18F72)
Release Type: User
Baseband Version: 3.04.01
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x8000000000000010 -> 0x0000000000000010 (possible pointer authentication failure)
VM Region Info: 0x10 is not in any region. Bytes before following region: 4339515376
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
--->
__TEXT 102a7c000-102a94000 [ 96K] r-x/r-x SM=COW ...APPNAME.app/APPNAME
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL,Code 0xb
Terminating Process: exc handler [11770]
Triggered by Thread: 3
Thread 3 name:
Thread 3 Crashed:
0 libswiftCore.dylib 0x00000001a53face4 swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::incrementSlow(swift::RefCountBitsT<(swift::RefCountInlinedness)1>,unsigned int) + 60 (atomic:1003)
1 libswiftCore.dylib 0x00000001a53c59e0 swift_retain + 124 (RefCount.h:813)
2 libswiftCore.dylib 0x00000001a5401d60 swift_bridgeObjectRetain + 56 (SwiftObject.mm:585)
3 APPNAME 0x0000000102b59734 closure #1 in discussionViewController.fetchPostData() + 7916
4 APPNAME 0x0000000102ad09d4 thunk for @escaping @callee_guaranteed (@guaranteed Data?,@guaranteed NSURLResponse?,@guaranteed Error?) -> () + 132 (<compiler-generated>:0)
5 CFNetwork 0x00000001a1b0a3dc __40-[__NSURLSessionLocal taskForClassInfo:]_block_invoke + 540 (LocalSession.mm:687)
6 CFNetwork 0x00000001a1b1c768 __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke + 244 (LocalSessionTask.mm:584)
7 libdispatch.dylib 0x00000001a10d1a84 _dispatch_call_block_and_release + 32 (init.c:1466)
8 libdispatch.dylib 0x00000001a10d381c _dispatch_client_callout + 20 (object.m:559)
9 libdispatch.dylib 0x00000001a10db004 _dispatch_lane_serial_drain + 620 (inline_internal.h:2557)
10 libdispatch.dylib 0x00000001a10dbc34 _dispatch_lane_invoke + 456 (queue.c:3862)
11 libdispatch.dylib 0x00000001a10e64bc _dispatch_workloop_worker_thread + 764 (queue.c:6589)
12 libsystem_pthread.dylib 0x00000001ed04a7a4 0x1ed047000 + 14244
13 libsystem_pthread.dylib 0x00000001ed05174c 0x1ed047000 + 42828
我已验证 discussionViewController.fetchPostData()
不会强制解开任何可选选项,没有 try!
并且在任何地方都使用 [weak self]
和 self?
。该函数非常大,所以我很难缩小崩溃发生的范围。
iOS TableView reloadData 刷新列表 cell 乱跳、tableview 闪动的问题。
解决方法:
在 iOS 11Self-Sizing 自动打开后,contentSize 和 contentOffset 都可能发生改变。可以通过以下方式禁用
self.estimatedRowHeight = 0;
self.estimatedSectionHeaderHeight = 0;
self.estimatedSectionFooterHeight = 0;
在 iOS 10 以下 通过以下协议方法设置精准高度就可以了
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath NS_AVAILABLE_IOS(7_0);
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForHeaderInSection:(NSInteger)section NS_AVAILABLE_IOS(7_0);
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForFooterInSection:(NSInteger)section NS_AVAILABLE_IOS(7_0);
ios UISearchController
1.searchResultsUpdater:设置显示搜索结果的控制器
_mySearchController.searchResultsUpdater = self;
2.dimsBackgroundDuringPresentation:设置开始搜索时背景显示与否
_mySearchController.dimsBackgroundDuringPresentation = NO;
3.[searchBar sizeToFit]: 设置 searchBar 位置自适应
[_mySearchController.searchBar sizeToFit];
4. 设置 searchBar 为 UITableView 的头部视图
self.myTableView.tableHeaderView = self.mySearchController.searchBar;
5.UISearchResultsUpdating: 代理方法
话不多说,直接上代码
@interface ViewController ()
@property (nonatomic, strong) UITableView *myTableView;
@property (nonatomic, strong) NSMutableArray *visableArray;
@property (nonatomic, strong) NSMutableArray *filterArray;
@property (nonatomic, strong) NSMutableArray *dataSourceArray;
@property (nonatomic, strong) UISearchController *mySearchController;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self initial];
}
- (void)initial{
self.dataSourceArray = [NSMutableArray array];
self.filterArray = [NSMutableArray array];
for (int i = 0; i < 26; i++) {
for (int j = 0; j < 4; j++) {
NSString *str = [NSString stringWithFormat:@"%c%d", ''A''+i, j];
[self.dataSourceArray addObject:str];
}
}
self.visableArray = self.dataSourceArray;
self.myTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
_myTableView.delegate = self;
_myTableView.dataSource = self;
[self.view addSubview:_myTableView];
self.mySearchController = [[UISearchController alloc] initWithSearchResultsController:nil];
_mySearchController.searchResultsUpdater = self;
_mySearchController.dimsBackgroundDuringPresentation = NO;
[_mySearchController.searchBar sizeToFit];
self.myTableView.tableHeaderView = self.mySearchController.searchBar;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (!_visableArray || _visableArray.count == 0) {
_visableArray = _dataSourceArray;
}
return _visableArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"identifier"];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"identifier"];
}
cell.textLabel.text = [_visableArray objectAtIndex:indexPath.row];
return cell;
}
- (void)updateSearchResultsForSearchController:(UISearchController *)searchController{
NSString *filterString = searchController.searchBar.text;
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF contains [c] %@", filterString];
self.visableArray = [NSMutableArray arrayWithArray:[self.dataSourceArray filteredArrayUsingPredicate:predicate]];
[self.myTableView reloadData];
}
关于tableView 中的 Swift 第一个单元格丢失了,因为添加了 UISearchController和swiftui 列表的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于Apple Pay 按钮的设计不正确,因为添加了“Apple Pay”、iOS Swift 应用程序随机 EXC_BAD_ACCESS 崩溃:swift_bridgeObjectRetain swift_retain swift::RefCounts
本文标签: