TableViewCell's items are null

Hi, I try to add tableviewcell to a table, but the elements of cell are null. So I can’t set data for elements.

Anyone can help?

Thanks.

Hi,

You can check out our RssReader sample for an example on how to use TableViewCells.

If you need more help, please post the relevant part of your code here so we can take a look.

Best Regards,
Gergely

In my project I use tableView in a UIViewController so the sample not working.

Dear Máté Illés,

the difference between a UITableViewController and a UIViewController with a UITableView inside it is basically, that the UITableViewController sets itself as datasource and delegate for its own UITableView. You need to set these manually.

However this is most likely not your current issue. You say the “cells are null”. What are you using to retrieve the cells?
Take a look at Apple’s documentation: Creating Table View Cells.

If this did not solve your issue, please PM us a project where we can reproduce this issue.

Hi,

I tried, what you suggest to me. It is not working.

https://[email protected]/mateilles718/rssreader.git this project. I think you have permission to see this.

I try to add cell at MyViewController (from row 144)

Thanks

Dear Máté Illés,

even null after initWithStyleReuseIdentifier? Try to register a class for reuse identifier before using the table view:

tableView.registerClassForCellReuseIdentifier(
    new org.moe.natj.objc.Class(UITableViewCell.class), "<reuse ID>");

The initWithStyleReuseIdentifier line should not be necessary at all, dequeueReusableCellWithIdentifier takes care of initialization.

Hi,

I did this:

tableView.registerClassForCellReuseIdentifier(
new org.moe.natj.objc.Class(RssFeedViewCell.class), “RssFeedCell”);

    UITableViewDataSource uiTableViewDataSource = new UITableViewDataSource() {
        @Override
        public UITableViewCell tableViewCellForRowAtIndexPath(UITableView uiTableView, NSIndexPath nsIndexPath) {

            String simpleTableIdentifier = "RssFeedCell";

            RssFeedViewCell cell = (RssFeedViewCell) uiTableView.dequeueReusableCellWithIdentifier(simpleTableIdentifier);

            cell.title().setText(filteredLisFeed.get((int) nsIndexPath.row()).title);
            cell.detail().setText(filteredLisFeed.get((int) nsIndexPath.row()).description);

            cell.addGestureRecognizer(gestureRecognizer);

            //set color
            cell.setTextColor(ThemeManager.theme);


            return cell;
        }

and now I get this error:
2016-10-12 15:50:31.234 ios[73666:3422282] -[com.intel.inde.moe.samples.rssreader.ios.ui.RssFeedViewCell title]: unrecognized selector sent to instance 0x7b214200
org.moe.natj.objc.ObjCException: -[com.intel.inde.moe.samples.rssreader.ios.ui.RssFeedViewCell title]: unrecognized selector sent to instance 0x7b214200
at ios.uikit.c.UIKit.UIApplicationMain(Native Method)
at com.intel.inde.moe.samples.rssreader.ios.Main.main(Main.java:25)

Dear Máté Illés,

I can’t see this class (RssFeedViewCell) in your repo, does it extend from UITableViewCell? Do you have @RegisterOnStartup annotation on that class?

Also, do you implement the alloc method?

@Owned
@Selector("alloc")
public static native RssFeedViewCell alloc();

Sorry I forgot to tell, it is at addCustomCell branch

Dear Máté Illés,

try putting the @RegisterOnStartup annotation on the RssFeedViewCell class.

After I modified, I get this:

java.lang.NullPointerException: Attempt to invoke virtual method ‘void ios.uikit.UITextView.setText(java.lang.String)’ on a null object reference
at com.intel.inde.moe.samples.rssreader.ios.ui.MyViewController$1.tableViewCellForRowAtIndexPath(MyViewController.java:155)
at ios.uikit.c.UIKit.UIApplicationMain(Native Method)
at com.intel.inde.moe.samples.rssreader.ios.Main.main(Main.java:25)