我有一个tableview,有时可能没有任何结果列出,所以如果没有结果(标签或一个表视图单元?),我想提出一些说"没有结果"的东西.
有最简单的方法吗?
我会尝试在label后面tableview根据结果隐藏其中一个,但是因为我正在使用a TableViewController而不是正常ViewController我不确定那是多么聪明或可行.
我也使用Parse和子类化为PFQueryTableViewController:
@interface TableViewController : PFQueryTableViewController
Run Code Online (Sandbox Code Playgroud)
我可以提供所需的任何其他详细信息,请告诉我!
TableViewController 故事板中的场景:

编辑: Per Midhun MP,这是我正在使用的代码
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
NSInteger numOfSections = 0;
if ([self.stringArray count] > 0)
{
self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
numOfSections = 1;
//yourTableView.backgroundView = nil;
self.tableView.backgroundView = nil;
}
else
{
UILabel *noDataLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.tableView.bounds.size.width, self.tableView.bounds.size.height)];
noDataLabel.text = @"No data available";
noDataLabel.textColor = [UIColor blackColor];
noDataLabel.textAlignment = …Run Code Online (Sandbox Code Playgroud) 我收到这些错误:

我不清楚它究竟在说什么?

如果它是42毫米2倍,那么我没有一个位置.你能帮我吗?谢谢!

编辑:下面的评论,我在右侧窗格中查看.看起来需要44 2x ......


...所以我创建了一个,但是Unassigned当我将图标拖到它上面时没有突出显示,那么如何在我的图像资源中分配它?

再次编辑:右键单击show in finder?

我有一个UITableViewController使用Xcode 8和Swift 3正确调整单元格大小的位置.现在我正在使用Xcode 9和Swift 4,它们不会扩展,只使用默认高度44.
(我每个人都有一两句话UITableViewCell)
我以前用过这个:
// MARK: - Table view delegate
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
override func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
Run Code Online (Sandbox Code Playgroud)
...但是能够对其进行评论,因为根据iOS 11更新你的应用程序说默认会自动调整大小:
我已经尝试过将部署目标更改为iOS 11,在Storyboard中玩游戏(但我使用的是Table View Cell样式Basic,所以没有太多AutoLayout要做),我无法弄清楚是什么正在进行.
我将UILabel标题设置为0行,并且具有换行字换行,但仍然没有得到任何接近于根据Xcode 9中的文本内容扩展单元格.任何想法?
谢谢!
编辑:
这是固定的选项(我没有),因为它是一个基本单元格:
我不能在我的应用程序中显示任何卡路里/ activeEnergyBurned,并且不知道为什么?
WorkoutInterfaceController:
private func totalCalories() -> Double {
return totalEnergyBurned.doubleValue(for: HKUnit.kilocalorie())
}
private func setTotalCalories(calories: Double) {
totalEnergyBurned = HKQuantity(unit: HKUnit.kilocalorie(), doubleValue: calories)
}
func startQuery(quantityTypeIdentifier: HKQuantityTypeIdentifier) {
let datePredicate = HKQuery.predicateForSamples(withStart: workoutStartDate, end: nil, options: .strictStartDate)
let devicePredicate = HKQuery.predicateForObjects(from: [HKDevice.local()])
let queryPredicate = NSCompoundPredicate(andPredicateWithSubpredicates:[datePredicate, devicePredicate])
let updateHandler: ((HKAnchoredObjectQuery, [HKSample]?, [HKDeletedObject]?, HKQueryAnchor?, Error?) -> Void) = { query, samples, deletedObjects, queryAnchor, error in
self.process(samples: samples, quantityTypeIdentifier: quantityTypeIdentifier)
}
let query = HKAnchoredObjectQuery(type: HKObjectType.quantityType(forIdentifier: quantityTypeIdentifier)!,
predicate: queryPredicate,
anchor: …Run Code Online (Sandbox Code Playgroud) 我有一个带有a的iOS + Watch应用程序UIPicker,并且我不断得到与之相关的日志,我无法弄清楚与Watch应用程序相关:
[默认] - [SPRemoteInterface handlePlistDictionary:fromIdentifier:]:2977:ComF: - >插件方法.pickerFocus未由控制器实现(null)
[default] - [SPRemoteInterface handlePlistDictionary:fromIdentifier:]:2977:ComF: - >插件方法.pickerClearFocus未由控制器实现(null)
我检查了文件和我能找到的最接近的是刚刚的pickerDidFocus()方法,这似乎是在谈论我有一般问题区,但对于具体没有明确的实施思路.pickerClearFocus和.pickerFocus.
我正在尝试实现新Codable协议,所以我添加Codable到我的结构中,但我坚持解码JSON.
这是我以前的所作所为:
结构 -
struct Question {
var title: String
var answer: Int
var question: Int
}
Run Code Online (Sandbox Code Playgroud)
客户 -
...
guard let data = data else {
return
}
do {
self.jsonResponse = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [String: Any]
let questionItems = self.jsonResponse?["themes"] as! [[String: Any]]
questionItems.forEach {
let item = Question(title: $0["title"] as! String,
answer: $0["answer"] as! Int,
question: $0["question"] as! Int)
questionData.append(item)
}
} catch {
print("error")
}
Run Code Online (Sandbox Code Playgroud)
这就是我现在所拥有的,除了我无法弄清楚解码器部分:
结构 …
我在WatchKit扩展中获得了所需的所有数据(从iOS应用程序传递).
我使用WatchKit中的数据InterfaceController填写表格,该表格完美无缺.
我正试图找出在WatchKit中获取相同数据ComplicationController的最佳方法.
目前,在InterfaceController,使用didReceiveUserInfo以下内容传递数据:
func session(session: WCSession, didReceiveUserInfo userInfo: [String : AnyObject]) {
if let beachValue = userInfo["Surf"] as? String {
places.append(Place(dataDictionary: ["Surf" : surfValue]))
} else {
print("Something went wrong")
}
}
Run Code Online (Sandbox Code Playgroud)
我是否需要WCSession在我的同一个方法中调用相同的方法ComplicationController并重新获取整个数据,或者是否有更简单的方法来访问相同的数据以供在中使用ComplicationController?
任何帮助赞赏.谢谢!
编辑:
我的表功能:
func makeTable() {
// Per SO
let myDelegate = WKExtension.sharedExtension().delegate as! ExtensionDelegate
let accessVar = myDelegate.places
self.rowTable.setNumberOfRows(accessVar.count, withRowType: "rows")
for (index, evt) in accessVar.enumerate() …Run Code Online (Sandbox Code Playgroud) 我运行carthage bootstrap --platform iOS并得到"Skipped安装realm-cocoa.framework二进制文件由于错误:不兼容的Swift版本 - 框架是用3.1构建的,本地版本是4.0",然后在构建结束时,我得到了一个完整的"构建失败:任务失败,退出代码为65"错误.
它指向了我derivedDataPath,并检查了xcodebuild日志以获取更多详细信息,它让我知道"PhaseScriptExecution Download\Core\and\Sync /Users/user/Libary/Caches/org.carthage.CarthageKit/DerivedData/9.0_9A## #/ realm-cocoa/v2.10.2/Build/Intermediates.noindex/Realm.build/Release-iphoneos/Realm.build/Script-X#X#X#X#X.sh(1 failure)".
但是我仍然不能完全确定Realm Cocoa到底发生了什么,或者如何修复,你知道吗?
我有一个<Podspec file name>.podspec相当于标准的GRPC.
我不知道如何在这里运行生成新的脚本 .pbobjc.h/.pbobjc.m files for each .proto file.
有谁知道我应该在命令行中运行什么命令来触发根据文件中的脚本生成这些新.podspec文件?
以下是脚本的更多上下文.podspec:
# Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients.
# You can run this command manually if you later change your protos and need to regenerate.
# Alternatively, you can advance the version of this podspec and run `pod update`.
s.prepare_command = <<-CMD
mkdir -p #{dir}
#{protoc} \
--plugin=protoc-gen-grpc=#{plugin} \
--objc_out="Pods/LndRpc" \
--grpc_out="Pods/LndRpc" …Run Code Online (Sandbox Code Playgroud) 我将数据从iOS传递到WatchKit. 我无法得到数据显示在WatchKit方面收到的某种方式.
这很好用:iOS TableViewController
func getCloudKit() {
///...
let publicData = container.publicCloudDatabase
publicData.performQuery(query, inZoneWithID: nil) { results, error in
if error == nil { // There is no error
for play in results! {
let newPlay = Play()
newPlay.tColor = play["TColor"] as! String
do {
try WatchSessionManager.sharedManager.updateApplicationContext(["color" : newPlay.tColor])
NSLog("NewPColor: %@", newPlay.tColor)
} catch {
print(error)
}
self.objects.append(newPlay)
}
} else {
print(error)
}
}
}
Run Code Online (Sandbox Code Playgroud)
这不是调用任何NSLogs或显示任何数据:WatchKitInterfaceController
import WatchConnectivity
class InterfaceController: WKInterfaceController, WCSessionDelegate {
@IBOutlet var …Run Code Online (Sandbox Code Playgroud) ios ×7
swift ×7
watchkit ×4
xcode ×4
objective-c ×2
uitableview ×2
watchos-2 ×2
apple-watch ×1
autolayout ×1
carthage ×1
cocoapods ×1
codable ×1
grpc ×1
healthkit ×1
realm ×1
uipickerview ×1
xcode6 ×1