我正在尝试从另一个类重新加载我的表。但是看来我做不到。

myclass1.h
@interface CalendarViewController : UIViewController <UITableViewDelegate,UITableViewDataSource> {


UITableView *tablo;

myclass1.m

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
    }


// Configure the cell...
cell.textLabel.text=@"mytext";

    return cell;
}

and myclass2.m
`(NSDate*) dateSelected{

    CalendarViewController *cal1=[[CalendarViewController

alloc]initWithNibName:@"CalendarViewController" bundle:nil];
[cal1.tablo  reloadData];


}


我不知道该如何解决。谁能帮我?

最佳答案

如果声明了iVar而不是使用@property和@synthesize,则必须自己创建getter和setter。

代替标头中的UITableView *tablo;代替:

@interface CalendarViewController : UIViewController

@property(nonatomic, strong)UITableView *tablo;

@end


然后在执行文件中:

@synthesize tablo = _tablo;

然后,您应该可以访问cal1.tablo

关于ios - 如何从其他类(class)重新加载表?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9506957/

10-10 14:42