Reputation: 2263
I have a table view, which was added in Interface Builder. How can I get its instance in the view controller?
Is there a way like in Android by using getViewById()
?
And if so where do I give the view its id?
Upvotes: 2
Views: 1755
Reputation: 510
I think you are starter in iPhone sdk, the solution goes as follows:
IBOutlet UITableview * myTableView;
TableView
from the xib to the files owner, there the name of the TableView
will appear.Tableview
.Upvotes: 5
Reputation: 47049
Create and add UITableView
programmatically and use it object (This is only for UITableView
).
self.tblView = [[UITableView alloc] init];
self.tblView.frame = CGRectMake(0, 87, self.view.frame.size.width, 374);
self.tblView.delegate = self;
self.tblView.dataSource = self;
[self.view addSubview:self.tblView];
Here self.tblView
is object of UITableView
you can use it as per your requirement.
Or get each object of subview of UIView
NSArray *subViewArray = [self.view subviews];
for (id obj in subViewArray)
{
// here **`obj`** get each object of subView of UIView.
}
Upvotes: 0