Skip to content

Commit

Permalink
fix(ios): setting TableView row layout to "horizontal" or "vertical" …
Browse files Browse the repository at this point in the history
…crashes (#11809)

Fixes TIMOB-28001
  • Loading branch information
vijaysingh-axway committed Jul 14, 2020
1 parent a378d21 commit fd53a51
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion iphone/TitaniumKit/TitaniumKit/Sources/API/TiViewProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -1647,7 +1647,7 @@ - (void)makeViewPerformSelector:(SEL)selector withObject:(id)object createIfNeed
{
BOOL isAttached = [self viewAttached];

if (!isAttached && !create) {
if ((!isAttached && !create) || ![[self view] respondsToSelector:selector]) {
return;
}

Expand Down
62 changes: 62 additions & 0 deletions tests/Resources/ti.ui.tableview.addontest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Appcelerator Titanium Mobile
* Copyright (c) 2015-Present by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
/* eslint-env mocha */
/* eslint no-unused-expressions: "off" */
'use strict';
const should = require('./utilities/assertions');

describe('Titanium.UI.TableView', function () {
this.timeout(5000);

let win;
afterEach(done => { // fires after every test in sub-suites too...
if (win && !win.closed) {
win.addEventListener('close', function listener () {
win.removeEventListener('close', listener);
win = null;
done();
});
win.close();
} else {
win = null;
done();
}
});

it.ios('rows with vertical or horizontal layout', function (finish) {
var tableData = [];
for (var index = 1; index <= 20; index++) {
var rowLayout = 'vertical';
if (index > 10) {
rowLayout = 'horizontal';
}
var row = Ti.UI.createTableViewRow({
layout: rowLayout
});
row.add(Ti.UI.createLabel({ text: 'Row ' + index.toString() }));

tableData.push(row);
}
var table = Ti.UI.createTableView({
data: tableData
});
win = Ti.UI.createWindow();

function addTableView() {
try {
// After adding table, app should not crash
win.add(table);
finish();
} catch (err) {
finish(err);
}
}

win.addEventListener('postlayout', addTableView);
win.open();
});
});

0 comments on commit fd53a51

Please sign in to comment.