How to add subview inside UIAlertView for iOS 7?

前端 未结 6 2068
悲哀的现实
悲哀的现实 2020-11-27 15:41

I am having an application on iTunes store which displays some UILabel and UIWebView on UIAlertView. According to session video,

6条回答
  •  一个人的身影
    2020-11-27 16:06

    A solution is to subclass UIAlertView and detect the "_UIModalItemAlertContentView" view. My AlertView had a UITextField, so I used it to detect the content view :

    - (void)show
    {
        [ super show ];
        UIView *contentView=nil;
        if([[[UIDevice currentDevice] systemVersion] floatValue ] < 7.0f)
        {
            contentView=self;
        } else {
            UIView *rootView=[self textFieldAtIndex:0];
            while((rootView=[rootView superview])!=nil)
            {
                if([ NSStringFromClass([rootView class]) isEqualToString:@"_UIModalItemAlertContentView"])
                {
                    contentView=rootView;
                    break;
                }
            }
        }
    
        if(contentView!=nil)
        {
            [ contentView addSubview: ... ];
        }
    }
    

提交回复
热议问题