我想在iOS 11中使用Xcode 8.
我应该升级我的Xcode.但是,我的代码不能由新编译器构建,所以我想继续使用Xcode 8.
我怎样才能做到这一点?
Apple在2017年WWDC上发布了几个新的iOS 11功能.
这是我想要做的一个例子:
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError)
{
let nm = NetworkModel()
nm.sendlog("file name :AppDelegate , line number : 288", info: " Failed to register: \(error)")
}
Run Code Online (Sandbox Code Playgroud)
目前的情况下我做的是硬编码值line number
和file name
.但是有可能以编程方式选择line number
和file name
.
我正在尝试使用Cocoapod在我的swift应用程序中安装Firebase,如下所示:
pod 'Firebase/Core'
pod 'Firebase/Messaging'
Run Code Online (Sandbox Code Playgroud)
但是当我处理pod安装时遇到错误:
[!] Error installing nanopb
[!] /usr/bin/curl -f -L -o /var/folders/82/qk0yjdtx5xl0hnzsk2s2h30h0000gn/T/d20170722-19429-tm6t4q/file.tgz http://koti.kapsi.fi/~jpa/nanopb/download/nanopb-0.3.8.tar.gz --create-dirs --netrc-optional
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 330 100 330 0 0 1941 0 --:--:-- --:--:-- --:--:-- 1952
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (22) The requested URL returned error: 503 Service Unavailable
Run Code Online (Sandbox Code Playgroud)
只是服务器下来?或者我错过了什么没有nanopb还有其他办法吗?
我有一个适用于静态单元格表视图的应用程序.在某些情况下,需要隐藏一些细胞,并在需要时再次显示它们.我怎样才能做到这一点 ?
我有一个集合视图,您可以在其中选择要删除的多个单元格.这意味着如果删除多个单元格,则还应在Realm中删除多个对象 - 每个单元格1个对象.
我有一个函数,它接受一个数组,这些数组Int
将从集合视图的选定indexPaths中填充.
问题是我不知道如何做到这两点
1)删除Realm中的对象和
2)拥有List
最新的没有删除的对象
我的代码是:
我像这样得到索引路径:
let indexPaths = collectionView.indexPathsForSelectedItems
这是我接受indexPaths,更新List
和删除Realm中对象的函数.它目前无法正常工作,因为没有删除对象.我注意到removeAll
没有删除任何东西.
func removeVideos(at indexes: [Int]) {
let newVideos = List<Video>()
for (index, video) in favorite!.videos.enumerated() {
if !indexes.contains(index) {
newVideos.append(video)
}
}
let realm = try! Realm()
try! realm.write {
favorite!.videos.removeAll()
newVideos.forEach { newVideo in
favorite!.videos.append(newVideo)
}
}
}
Run Code Online (Sandbox Code Playgroud)
我这样调用这个函数:
removeVideos(at: indexPaths.map { $0.item })
有什么想法吗?
我正在寻找Swift3中的解决方案来同时解决动态数量的promise,例如像JavaScript中的这个示例:
var promises = [];
for(var i = 0; i < 5; i++) {
var promise = $http.get('/data' + i);
promises.push(promise);
}
$q.all(promises).then(doSomethingAfterAllRequests);
Run Code Online (Sandbox Code Playgroud)
https://daveceddia.com/waiting-for-promises-in-a-loop/
有一个库可以为Swift2调用'Craft',可以做到这一点(https://github.com/supertommy/craft),但它不再维护.
有没有人知道我是否或如何使用PromiseKit或其他图书馆做到这一点?
好一堆!
由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“更新无效:部分数量无效。” 更新后表视图中包含的节数 (3) 必须等于更新前表视图中包含的节数 (3),加上或减去插入或删除的节数(1 个插入,0 个已删除)。
但我根据我错过的数据源插入 1 并删除 1
self.states?.append(sortedStates) //Update state property
if (self.states?.count)! > 3 {
self.states?.removeFirst()
}
self.newsFeedTableView.beginUpdates()
self.newsFeedTableView.insertSections([(self.states?.count)! - 1], with: .none)
if (self.states?.count)! > 3 {
let statesForoldestStateTime = self.states?.first
self.newestStateTime = statesForoldestStateTime?.first?.createdAt
let indexpostion = (self.states?.count)! - 3
self.newsFeedTableView.deleteSections([indexpostion], with: UITableViewRowAnimation.none)
}
self.newsFeedTableView.endUpdates()
Run Code Online (Sandbox Code Playgroud) 在 RecyclerView 上,在项目大小结束时以及向上滚动到 RecyclerView 顶部时,addOnScrollListener
该属性需要一些时间才能被调用。SCROLL_STATE_IDLE
但在滚动过程中效果很好。
布局的根视图是CoordinatorLayout。
scroll android-layout onscrolllistener android-recyclerview android-coordinatorlayout
UITableView
在Swift 中使用 a ,有人可以帮我根据标签、图片和描述自动更改单元格的高度吗?
我想随着标签文本的增加动态更改单元格大小。我已经在标签上应用了自动布局。
swift ×7
ios ×5
uitableview ×3
autolayout ×1
cocoapods ×1
firebase ×1
ios11 ×1
laravel ×1
php ×1
promise ×1
promisekit ×1
realm ×1
realm-list ×1
scroll ×1
swift3 ×1
xcode ×1