UI issue with nil title in UIAlertView iOS 8 beta 5

前端 未结 4 1258
栀梦
栀梦 2021-02-13 10:41

I have an issue related to UIAlertView while running our app on iOS 8. I am showing an alert with title as nil. It was working fine in iOS 7 but now UI looks odd.

I ha

4条回答
  •  粉色の甜心
    2021-02-13 11:22

    It has been the best practice for me to use initWithTitle:@"" for UIAlertView, UIActionSheet since iOS 6 because I was facing a design issue during that time when I was using initWithTitle:nil. I tried to find back, I couldn't find it what exactly is the reason.

    From your screen shot on iOS 8, I think there is a change of view hierarchy on UIAlertView for iOS 8. I think Auto layout might be implemented on the view hierarachy as well as you can see the messageLabel jump up to the titleLabel.

    I can not be sure because the view hierarchy for UIAlertView is private.

    The UIAlertView class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified.

    See: https://developer.apple.com/library/ios/documentation/uikit/reference/UIAlertView_Class/UIAlertView/UIAlertView.html

    But, I use the code:-

    NSLog(@"%@",[self.alertView description]);
    

    Result on iOS 7.1:

    >
    

    Result on iOS 8.0:

    >
    

    I am not sure why the UIAlertView frame for iOS 8 is (0 0; 0 0);

    Like Mike said, I think you should learn to use UIAlertController for iOS 8.

提交回复
热议问题