简体   繁体   中英

Removing UIView from NSArray

I have a UIView called SGAdressLabel that I store in emailLabelsArray .

At some point, I want to delete all the UIViews from their superviews while keeping them in my array. I do a thing like this and nothing happens:

for (SGAdressLabel *tmpLabel in emailLabelsArray)
    {
        NSLog(@"Removing labels!");
        [tmpLabel removeFromSuperview];
    }

The NSLog message appears for as many times as there are objects in the Array but still, nothing happens. What's the problem here?

Try :

for (SGAdressLabel __strong *tmpLabel in emailLabelsArray)
{
    NSLog(@"Removing labels!");
    tempLabel = (SGAdressLabel *)tmpLabel;
    [tmpLabel removeFromSuperview];
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM