首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Iphone >

怎么调用类中的方法

2012-01-30 
如何调用类中的方法?SwitchViewController类中有一个方法-(IBAction)switchDetailViews:(id)sender{}想实

如何调用类中的方法?
SwitchViewController类中有一个方法
-(IBAction)switchDetailViews:(id)sender
{
}


想实现点击tableview一行,显示一个view,

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 
SwitchViewController *switchViewController=[[SwitchViewController alloc] init];
  [switchViewController switchViews];
  [switchViewController release];
}

但是显示不了。在界面的按钮直接连线到switchViews这个方法就可以执行

[解决办法]
显示不了,我猜是因为当前加载的View是tableView,需要翻页或者覆盖这个tableView。
点击一行肯定会触发
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
在这里试一下
UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)];
v.backgroundColor = [UIColor purpleColor];
[self.view addSubview:v];

热点排行