0
我正在用Appcelerator Titanium創建一個簡單的聊天應用程序來測試框架,並使用簡單的TableView來顯示消息列表。當我滾動表格以便加載之前不可見的行時,應用程序會立即使用Objective-C跟蹤(請參見下文)崩潰。我完全不知道如何理解這一點,但大部分堆棧顯然是庫代碼。iOS Titanium應用程序在滾動時崩潰TableView
[ERROR] : The application has crashed with an uncaught exception 'NSInvalidArgumentException'.
[ERROR] : Reason:
[ERROR] : -[__NSCFString absoluteString]: unrecognized selector sent to instance 0xae71df0
[ERROR] : Stack trace:
[ERROR] : 0 CoreFoundation 0x038fc012 __exceptionPreprocess + 178
[ERROR] : 1 libobjc.A.dylib 0x033bde7e objc_exception_throw + 44
[ERROR] : 2 CoreFoundation 0x039874bd -[NSObject(NSObject) doesNotRecognizeSelector:] + 253
[ERROR] : 3 CoreFoundation 0x038ebbbc ___forwarding___ + 588
[ERROR] : 4 CoreFoundation 0x038eb94e _CF_forwarding_prep_0 + 14
[ERROR] : 5 Mobile Chat 0x000e928b -[TiUIImageView loadUrl:] + 139
[ERROR] : 6 Mobile Chat 0x000eafe6 -[TiUIImageView setImage_:] + 902
[ERROR] : 7 libobjc.A.dylib 0x033d16b0 -[NSObject performSelector:withObject:] + 70
[ERROR] : 8 Mobile Chat 0x000f75f1 DoProxyDelegateReadKeyFromProxy + 321
[ERROR] : 9 Mobile Chat 0x000f7bf1 DoProxyDelegateReadValuesWithKeysFromProxy + 1137
[ERROR] : 10 Mobile Chat 0x00099f41 -[TiUIView readProxyValuesWithKeys:] + 65
[ERROR] : 11 Mobile Chat 0x00075427 -[TiViewProxy firePropertyChanges] + 167
[ERROR] : 12 Mobile Chat 0x00072c6e -[TiViewProxy view] + 1102
[ERROR] : 13 Mobile Chat 0x0017e8e5 -[TiUITableViewRowProxy redelegateViews:toView:] + 117
[ERROR] : 14 Mobile Chat 0x0018031f __43-[TiUITableViewRowProxy configureChildren:]_block_invoke_2 + 543
[ERROR] : 15 CoreFoundation 0x038f5e7c __NSArrayEnumerate + 572
[ERROR] : 16 CoreFoundation 0x038f5a16 -[NSArray enumerateObjectsWithOptions:usingBlock:] + 102
[ERROR] : 17 CoreFoundation 0x038f5925 -[NSArray enumerateObjectsUsingBlock:] + 53
[ERROR] : 18 Mobile Chat 0x0017fd34 -[TiUITableViewRowProxy configureChildren:] + 2900
[ERROR] : 19 Mobile Chat 0x00180725 -[TiUITableViewRowProxy initializeTableViewCell:] + 293
[ERROR] : 20 Mobile Chat 0x000c7660 -[TiUITableView tableView:cellForRowAtIndexPath:] + 944
[ERROR] : 21 UIKit 0x012748fb -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 412
[ERROR] : 22 UIKit 0x012749cf -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 69
[ERROR] : 23 UIKit 0x0125d1bb -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1863
[ERROR] : 24 UIKit 0x0126db4b -[UITableView layoutSubviews] + 241
[ERROR] : 25 UIKit 0x0120a2dd -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 279
[ERROR] : 26 libobjc.A.dylib 0x033d16b0 -[NSObject performSelector:withObject:] + 70
[ERROR] : 27 QuartzCore 0x02779fc0 -[CALayer layoutSublayers] + 240
[ERROR] : 28 QuartzCore 0x0276e33c _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 468
[ERROR] : 29 QuartzCore 0x0276e150 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
[ERROR] : 30 QuartzCore 0x026ec0bc _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 324
[ERROR] : 31 QuartzCore 0x026ed227 _ZN2CA11Transaction6commitEv + 395
[ERROR] : 32 QuartzCore 0x026ed8e2 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 96
[ERROR] : 33 CoreFoundation 0x038c4afe __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
[ERROR] : 34 CoreFoundation 0x038c4a3d __CFRunLoopDoObservers + 381
[ERROR] : 35 CoreFoundation 0x038a27c2 __CFRunLoopRun + 1106
[ERROR] : 36 CoreFoundation 0x038a1f44 CFRunLoopRunSpecific + 276
[ERROR] : 37 CoreFoundation 0x038a1e1b CFRunLoopRunInMode + 123
[ERROR] : 38 GraphicsServices 0x036837e3 GSEventRunModal + 88
[ERROR] : 39 GraphicsServices 0x03683668 GSEventRun + 104
[ERROR] : 40 UIKit 0x011b9ffc UIApplicationMain + 1211
[ERROR] : 41 Mobile Chat 0x000048f8 main + 456
[ERROR] : 42 Mobile Chat 0x00003205 start + 53
[ERROR] : 2013-09-24 10:49:02.969 Mobile Chat[35979:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString absoluteString]: unrecognized selector sent to instance 0xae71df0'
[ERROR] : *** First throw call stack:
[ERROR] : (0x38fc012 0x33bde7e 0x39874bd 0x38ebbbc 0x38eb94e 0xe928b 0xeafe6 0x33d16b0 0xf75f1 0xf7bf1 0x99f41 0x75427 0x72c6e 0x17e8e5 0x18031f 0x38f5e7c 0x38f5a16 0x38f5925 0x17fd34 0x180725 0xc7660 0x12748fb 0x12749cf 0x125d1bb 0x126db4b 0x120a2dd 0x33d16b0 0x2779fc0 0x276e33c 0x276e150 0x26ec0bc 0x26ed227 0x26ed8e2 0x38c4afe 0x38c4a3d 0x38a27c2 0x38a1f44 0x38a1e1b 0x36837e3 0x3683668 0x11b9ffc 0x48f8 0x3205)
-- End simulator log ---------------------------------------------------------
[ERROR] : An error occurred running the iOS Simulator
[ERROR] :
[ERROR] : Project failed to build after 12s 961ms
這裏是相關的代碼。這是一個文件,其功能從app.js稱爲低谷的導航控制器
var chatWindow = function(channelName) {
var chatRow = function(username, picture, message) {
var row = Titanium.UI.createTableViewRow();
var image = Titanium.UI.createImageView({
left: 5,
top: 5,
bottom: 5,
height: 50,
width: 50,
image: picture
});
var user = Titanium.UI.createLabel({
top: 5,
left: 60,
right: 5,
text: username,
font: {
fontWeight: "bold",
}
});
var msg = Titanium.UI.createLabel({
top: 30,
left: 60,
right: 5,
text: message
});
row.add(image);
row.add(user);
row.add(msg);
return row;
};
var window = Titanium.UI.createWindow({
width: Titanium.UI.FILL,
title: channelName,
backgroundColor: "#fff",
});
var container = Titanium.UI.createScrollView({
contentHeight: Titanium.UI.FILL,
contentWidth: Titanium.UI.FILL,
height: Titanium.UI.FILL,
width: Titanium.UI.FILL,
});
var textfield = Titanium.UI.createTextField({
borderStyle: Titanium.UI.INPUT_BORDERSTYLE_ROUNDED,
width: Titanium.UI.FILL,
height: Titanium.UI.FILL,
bottom: 10,
left: 10,
right: 10,
height: 30,
returnKeyType: Titanium.UI.RETURNKEY_SEND
});
var messages = Titanium.UI.createTableView({
width: Titanium.UI.FILL,
bottom: 50,
top: 0
});
textfield.addEventListener("return", function() {
if (textfield.getValue() != "") {
messages.appendRow({title:textfield.getValue()});
textfield.setValue("");
}
});
textfield.addEventListener("focus", function() {
setTimeout(function() {container.setScrollingEnabled(false);}, 100);
});
textfield.addEventListener("blur", function() {
setTimeout(function() {container.setScrollingEnabled(true);}, 100);
});
container.add(messages);
container.add(textfield);
window.add(container);
var loop = function(dateNow) {
var d = new Date();
connect.ServerLink("getMessages",
{
channel: channelName,
startTime: d.getYear().toString().concat("-")
.concat(d.getMonth()).concat("-")
.concat(d.getDay()).concat("T")
.concat(d.getHours()).concat(":")
.concat(d.getMinutes()).concat(":")
.concat(d.getSeconds()).concat(".")
.concat(d.getMilliseconds()).concat("Z")
},
function(content) {
var json = JSON.parse(content);
var rows = [];
for (var i = json.length-1; i >= 0; i--) {
rows.push(chatRow(json[i].author, json[i].content));
Titanium.API.debug(json[i]);
}
rows.sort(function(a, b){
return (Date.parse(a.time)-Date.parse(b.time));
});
messages.setData(rows);
},
null);
setTimeout(loop, 2000);
};
loop();
return window;
};
有沒有人有什麼原因造成這個錯誤的想法?
嗯論點,確實......我我總是被那些小東西所暗殺。只要SO允許,我會盡快接受 – Kroltan
它總是小事情;) – mwfire