开发者

issues with viewWithTag in iphone

开发者 https://www.devze.com 2023-03-31 05:58 出处:网络
I am using this method to delete 3 different stack object( A , B ,C) , but sometime delete order changes and it start deleting other stack object , lets say i click on A del button , but it delete B s

I am using this method to delete 3 different stack object( A , B ,C) , but sometime delete order changes and it start deleting other stack object , lets say i click on A del button , but it delete B stack button

// for A stack Deletion - (IBAction)delWhis:(id)sender {

if(j>1)
    {
    j--;

    [[self.view viewWithTag:j] removeFromSuperview];


        {
        NSLog(@" whisky  ration is  %d",width1);
        width1 = width1 +38;


        }


    }

}

// for B stack deletion - (IBAction)delWhiskkk:(id)sender {

if(ji>1)
    {
    ji--;

    [[self.view viewWithTag:ji] removeFromSuperview];


        {
        NSLog(@" whisky  ration is  %d",width1);
        width1 = width1 +38;


        }


    }
开发者_JS百科

}

anyidea how to fix this

thanks


[self.view viewWithTag:j] 

The above code returns The Object that Contains Tag As j in That Particular UiView.

for example Let Us Suppose j = 0. This will Return one View that has a tag of 0. If Suppose I have a UILabel, and UITextFeild have the same tags. Only the first in the view array will be removed, not both. So We Must Maintain Distinct Tags. By Default any view Tag IS 0. IT's best to try maintaining Distant Tags It Will Work Fine.


Well i got the ans, since all my 3 stacks A B C have tag value from 0 to 10 , so while deleting any of the stack if tag value matches any of the other Stack ABC then it start del them, so all tag increment counter must be different

thanks

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号