Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在按钮上使用标记并在下一个视图标签中传递标记值_Iphone - Fatal编程技术网

Iphone 在按钮上使用标记并在下一个视图标签中传递标记值

Iphone 在按钮上使用标记并在下一个视图标签中传递标记值,iphone,Iphone,我有一些按钮,其标签设置为1到10。现在,如果用户单击按钮,标签值应发送到下一个屏幕/nib的标签中 -(IBAction) gotoGameScreen:(id)sender { [self playAudio]; UIButton *btn=(UIButton *)sender; NSLog(@"Use Selected Level=%d",btn.tag);//here i am getting the tag value as 1. GameScr

我有一些按钮,其标签设置为1到10。现在,如果用户单击按钮,标签值应发送到下一个屏幕/nib的标签中

-(IBAction) gotoGameScreen:(id)sender  
{  
    [self playAudio];    
UIButton *btn=(UIButton *)sender;    
NSLog(@"Use Selected Level=%d",btn.tag);//here i am getting the tag value as 1.    
GameScreen *gameScreen = [[GameScreen alloc] initWithNibName:@"GameScreen" bundle:nil];    
[self.navigationController pushViewController:gameScreen animated:YES];    
[gameScreen release];  
}  
有什么建议吗?
感谢您在游戏屏幕中使用整数,定义属性并合成它,然后将当前按钮标签的值传递给下一个

-(IBAction) gotoGameScreen:(id)sender
{

[self playAudio];

UIButton *btn=(UIButton *)sender;

NSLog(@"Use Selected Level=%d",btn.tag);

GameScreen *gameScreen = [[GameScreen alloc] initWithNibName:@"GameScreen" bundle:nil];

gameScreen.tagValue=btn.tag;

[self.navigationController pushViewController:gameScreen animated:YES];

[gameScreen release];

}

这行不通。您应该做的是创建一个整数,例如

int iButtonTag;    
将其属性设置为

@property(nonatomic,assign) int iButtonTag; 
并将其合成

使用此int在按钮的标记上指定paas。此包含按钮标记的int将在下一个viewController中使用