0

I have a problem with opening a new view from my array buttons. I have a NSLog message in place that is outputting a int that all works fine.

How do I get this button to open a viewController with my tag as a parameter. This tag / parameter corresponds with a list of images that also seems to work fine.

How would I add this together?

Here is a code snippet from imageViewController.m:

-(void)thumbClickAction:(id)sender{


CustomImageView *club = (CustomImageView*)sender;

//debug line
NSLog(@"image tag : %d",club.tag);

I have no clue what I'm doing wrong I hope you can help me.

4

1 回答 1

2

把方法作为-(void)thumbClickAction:(UIButton *)sender例子
-(void)thumbClickAction:(id)sender

-(void)thumbClickAction:(UIButton *)sender
{
  NSLog(@"my button tag is - %d ",sender.tag);
  myNewViewController *newView = [[myNewViewController alloc] init];
  newView.myTag = sender.tag;
  [self presentModalViewController:newView animated:YES];
}

在上面的代码中,当您单击按钮时,创建对象myNewViewController会将您传递sender.tag给 variale myTagmyTagNSStringVariale on ),然后按钮的标签与at一起使用并根据需要触发 Query。myNewViewControllermyTagmyNewViewController

于 2013-04-17T12:19:14.030 回答