读书人

怎么调用类中的方法

发布时间: 2012-01-30 21:15:58 作者: rapoo

如何调用类中的方法?
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];

读书人网 >Iphone

热点推荐