【发布时间】:2015-03-04 11:07:15
【问题描述】:
我是 iOS 新手。我制作了一个包含 Scrollview 的应用程序,在 Scrollview 中我添加了 10 页,每页包含 12 个按钮,并在我的 Scrollview 之外设置一个停止按钮,我想在按下停止按钮时设置,然后我想隐藏我选择的按钮,但它不起作用但是当我点击视图中的同一个按钮时,它是隐藏的,但是在这里我想在点击停止按钮时隐藏选定的按钮,我写代码就像
-(void)clikedOnButton:(UIButton*)whichButtonClicked
{
SaveSoundIntoArray *saveInfointoArray=[SaveSoundIntoArray sharedInstance];
if(whichButtonClicked.selected)
{
NSLog(@"button selected is:%@",whichButtonClicked);
NSUInteger butTag=(long)whichButtonClicked.tag;
NSLog(@"button clicked is:%ld",butTag);
switch (butTag)
{
case 1:
{
[[self.view viewWithTag:2] setHidden:YES];
[[self.view viewWithTag:121] setHidden:YES];
[saveInfointoArray.stopAllPlayer removeObject:saveInfointoArray.player1]; //when unselect the button ,remove object from array
[saveInfointoArray.saveButtonName removeObject:whichButtonClicked]; //when unselect object button remove object from array
[saveInfointoArray.selectedButtonButNotMoreThanTen removeObject:whichButtonClicked];
[saveInfointoArray.VolumeSaveForPlayer removeObjectForKey:@"1"];
totalSelectedButtonButNotMoreThanTen=[SaveSoundIntoArray countTotalSelectedButton:-1 and:1 and:0];
whichButtonClicked.selected =NO;
[saveInfointoArray.player1 stop]; //tap=2 , player1 stop
}
break;
}
}
这个方法在我的 view1 中现在我在按下停止按钮时调用这个方法
- (IBAction)stopAllPlayers:(id)sender
{
view1=[[View1 alloc]init];
SaveSoundIntoArray *saveInfointoArray=[SaveSoundIntoArray sharedInstance];
if(saveInfointoArray.stopAllPlayer.count == 0)
{
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Selection Empty" message:@"Your Selection is Empty" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
else
{
for(int i=0;i<saveInfointoArray.stopAllPlayer.count;i++)
{
copyOfSaveButtonName[i]=saveInfointoArray.saveButtonName[i]; //copy bcz loop mathi method call kriye tyare remove object thay 6
copyOfStopAllPlayer[i]=saveInfointoArray.stopAllPlayer[i]; //copy bcz stopallplayer removeObject
copyOfSaveButtonTag[i]=saveInfointoArray.saveButtonTag[i]; //copy bcz savebuttonTag removeObject
}
for(int i=0;i<copyOfStopAllPlayer.count;i++) //error here
{
NSLog(@"button:%@ and Player:%@ is STOP",copyOfSaveButtonName[i],copyOfStopAllPlayer[i]);
NSLog(@"button Tag is:%@",copyOfSaveButtonName[i]);
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button=copyOfSaveButtonName[i];
button.selected=YES;
NSLog(@"tag is :%@",copyOfSaveButtonTag[i]);
int currentTag=[copyOfSaveButtonTag[i] intValue]; //use buttonTag for comparison of buttontags
NSLog(@"currentTag: %d",currentTag);
if(currentTag>=1 && currentTag<=12)
{
[view1 clikedOnButton:button];
}
}
这里我没有从停止按钮获得按钮标签,我不知道,因为我对此感到困惑,请帮助我
谢谢。
【问题讨论】:
标签: ios objective-c uiview uibutton