Objective c 例如: tblView = [[UITableView alloc] initWithFrame:CGRectMake(100,200,320,420) style: UITableViewStyleGrouped]; tblView.delegate = self; tblView.dataSource = self; [self.view addSubview:tblView];
您所指的这些方法是委托方法,与其他普通方法不同,它们不能直接激发Objective c 例如: tblView = [[UITableView alloc] initWithFrame:CGRectMake(100,200,320,420) style: UITableViewStyleGrouped]; tblView.delegate = self; tblView.dataSource = self; [self.view addSubview:tblView];,objective-c,xcode,Objective C,Xcode,您所指的这些方法是委托方法,与其他普通方法不同,它们不能直接激发 希望对你有帮助 确保已设置tableview的委托和数据源。请参阅重复:确保已设置tableview的委托和数据源。请参阅重复:确保已设置tableview的委托和数据源。请参阅重复:确保已设置tableview的委托和数据源。请参阅重复: - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sec
希望对你有帮助 确保已设置tableview的
委托和数据源
。请参阅重复:确保已设置tableview的委托和数据源
。请参阅重复:确保已设置tableview的委托和数据源
。请参阅重复:确保已设置tableview的委托和数据源
。请参阅重复:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return self.GPTNotifications.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
static NSString *CellIdentifierRead = @"CellRead";
UITableViewCell *cell;
notifications *n = [self.GPTNotifications objectAtIndex:indexPath.row];
if (n.read == false) {
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
CustomCellRead *cellReadB = (CustomCellRead *)cell;
cellReadB.notifTitle.text = n.notifTitleD;
cellReadB.notifDate.text = n.notifDateD;
cellReadB.notifMsg.text = n.notifMessage;
return cellReadB;
}
else {
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifierRead forIndexPath:indexPath];
CustomCell *cellReadB = (CustomCell *)cell;
cellReadB.notifTitle.text = n.notifTitleD;
cellReadB.notifDate.text = n.notifDateD;
cellReadB.notifMsg.text = n.notifMessage;
return cellReadB;
}
}
self.myTableView.delegate = self;
self.myTableView.dataSource = self;
@interface NotificationsListTVController : UIViewController <UITableViewDelegate, UITableViewDataSource>
@interface NotificationsListTVController : UIViewController<UITableViewDataSource,UITableViewDelegate>
tableView.delegate=self ;
tableView.dataSource=self;
tblView = [[UITableView alloc] initWithFrame:CGRectMake(100,200,320,420) style: UITableViewStyleGrouped];
tblView.delegate = self;
tblView.dataSource = self;
[self.view addSubview:tblView];