当前位置: 代码迷 >> Iphone >> 怎么调用类中的方法
  详细解决方案

怎么调用类中的方法

热度:150   发布时间:2016-04-25 06:50:05.0
如何调用类中的方法?
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];
  相关解决方案