I have a UITableView class that i am calling in another class
MyPocketTableView * myPocketTableView = [[MyPocketTableView alloc]initWithFrame:CGRectMake(85, 153, 235, 250) style:UITableViewStyleGrouped];
However, the init method in the UITableViewClass does not let me do this.
@implementation MyPocketTableView
- (id) initWithFrame:(CGRect)frame style:(UITableViewStyle)style {
self = [super initWithFrame:frame];
self = [super initWithStyle:style]
if (self) {
//[self setFrame:CGRectMake(85, 153, 235, 250)];
self.dataSource = self;
self.delegate = self;
}
return self;
}
I cannot add style : (UITableViewStyle) style on to the init method definition, nor can i do the self = [super initWithStyle:style] because it complains saying
No visible @interface for ‘UITableView’ declares the selector initWithStyle.
The default init method that was there when the class was created was - (id) initWithFrame:(CGRect)frame. MyPocketTableView is a sub class of UITableView.
@interface MyPocketTableView : UITableView <UITableViewDataSource,UITableViewDelegate>
You need to set the interface to
UITableViewController, then useinitWithStyle:.Also, in doing the following, there is no need to set the UITableView protocol delegates
Then you can call:
As well as the following:
You can also use the following (example) custom method: The key being you are calling: