开发者

What could I add to this code to make it not remove the UIToolbar?

开发者 https://www.devze.com 2023-04-01 16:45 出处:网络
NSArray *subviewsList = [[NSArray alloc] initWithArray:[self.view subviews]]; for (UIView *aView in subviewsList) {
    NSArray *subviewsList = [[NSArray alloc] initWithArray:[self.view subviews]];
for (UIView *aView in subviewsList) { 
    NSLog(@"%@",subviewsList);
    if (![aView isEqual:sender]) {
        [aView removeFromSuperview]; 
    }
}
[subviewsList release];

I have it not remove the UIButton that you click to actually call this code, however, I haven't figured out how to get it not to remove the UITool开发者_开发知识库bar that I added to the screen via IB. Any suggestions?

EDIT: I should have been more clear, I'm sorry. The code was done to remove the ton of UIImageViews from the screen. I didn't want it to remove the uibutton that calls the method, or the toolbar.

EDIT:

This works. :)

    if (![aView isEqual:sender] && ![aView isKindOfClass:[UIToolbar class]]) {


If ([aView isKindOfClass:[UIToolBar class]]) {
    // the view is a uitoolbar
} else {
   [aView removeFromSuperView];
}

Send from iphone, maybe syntax errors :) but this let you check if your subview is from a specific class

Hope this helps


Any number of things could be happening. Is your UIToolbar a subview or sublayer of one of the aView's you are removing?

Without knowing what all else is happening in your views (in code or in IB), it's hard to say, but also make sure that if you're adding any views or layers that they're not covering anything up. (Even if something like a UIButton is visible, it may not respond if covered by another view.)

0

精彩评论

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