2

I have a 'Load More' UIButton inside a custom UITableViewCell. My table also uses a Delegate. I want to reload the table data when this button is clicked. I have noticed that when I click the button, nothing happens. But when I click on the area around the button i.e. the actual Cell, the Delegate gets the RowSelected event. I tried using SetSelected(true,false); from the button's touch up inside event to see if it would fire the RowSelected event for the delegate, but it didn't.

Can anyone explain me how I can make a button click for a Custom Table cell fire the actual Row Selected event? If this isn't a viable option, is there a better way to 'Load more data' other than placing the button inside a custom table view cell?

Thanks!

UPDATE: I do use ContentView.AddSubView as shown in the code below. Please note I'm using Monotouch, but the logic is the same:

            public LoadMoreCell (string reuseCellIdentifier)
        :base(UITableViewCellStyle.Default, reuseCellIdentifier)
    {
        SelectionStyle = UITableViewCellSelectionStyle.None;

        _btnLoadMore = UIButton.FromType(UIButtonType.RoundedRect);
        _btnLoadMore.Frame = new RectangleF(10,5,300,30);
        _btnLoadMore.SetTitle("Load More", UIControlState.Normal);
        _btnLoadMore.UserInteractionEnabled = true;
        ContentView.AddSubview(_btnLoadMore);


    }

I have a TableDelegate that has a RowSelected method where I reload the data...however, the RowSelected only gets fired when I click the actual row.

4

2 回答 2

1

I think you might have added the uibutton as

[self addSubView:yourButton];

instead use :-

[self.contentView addSubview:yourButton];

and all the other controls of your custom cell. Do this in the initializer of your custom cell :-

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {}
于 2012-05-18T09:55:38.910 回答
0

为您的表制作一个自定义 UITableViewDataSource,当您点击“加载更多”按钮时,调用此数据源的方法以将其他数据添加到数据源列表中,将此数据源添加到您的表中并确保重新加载桌子

this.tblData.ReloadData ();
于 2012-05-24T09:36:52.070 回答