Reputation: 5144
I have a created custom table view cell class named CustomCell
which inherits from UITableViewCell
.
I have also created xib file for the cell named CustomCell.xib
.
In the xib file, I have specified custom class to be the CustomCell
,
and also set the file's owner to be CustomCell
class.
Now, I have connected the some button touchUpInside
to be handled in the file's owner which is CustomCell
.
I load the cell with the following code in my table view controller:
NSArray *topLevelObjects = [[NSBundle mainBundle]
loadNibNamed:@"CustomCell" owner:nil options:nil];
cell = [topLevelObjects objectAtIndex: 0];
As you can see, the loaded cell does not have owner (owner:nil
parameter),
and the problem is that I need the owner to be set to cell itself.
How can I set the owner for the cell
explicitly?
Is there some other way to load xib and to make that cell instance become owner to itself?
Upvotes: 0
Views: 116
Reputation: 17143
If your cell and your button are both in the same nib, you can just make the connection between them inside the nib.
The "file's owner" proxy is just there to help you make a connection to an object that isn't in the nib. "File's owner" is just a proxy for the owner of this nib at runtime.
But since the two objects you wish to connect are both inside the nib already, you can just make that connection directly.
Upvotes: 1