2014-08-29 8 views
14

में आईआईएल मुद्दे के साथ यूआई समस्या आईओएस 8 पर हमारे ऐप को चलाने के दौरान यूआईएलर्टव्यू से संबंधित एक समस्या है। मैं शीर्षक के साथ शीर्षक के साथ एक चेतावनी दिखा रहा हूं। यह आईओएस 7 में ठीक काम कर रहा था लेकिन अब यूआई अजीब लग रहा है।UIAlertView आईओएस 8 में बीआईएल 5

मैंने यहां स्क्रीनशॉट संलग्न किया है।

enter image description here मुझे मिला एक समाधान यह है कि जब मैं खाली स्ट्रिंग प्रदान करता हूं तो यह ठीक दिखता है। नीचे स्क्रीनशॉट देखें। लेकिन मुझे यकीन नहीं है कि अगर मैंने जो मुद्दा बताया है वह बीटा आईओएस 8 संस्करण में बग है या कोई अन्य बेहतर समाधान है। समाधान के साथ भी यह सटीक नहीं कर रहा है के रूप में यह आईओएस 7 में

enter image description here

iOS 7 था

- शून्य के रूप में शीर्षक के साथ दिखा चेतावनी दृश्य। स्क्रीनशॉट यहाँ। ,,

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Location field required." message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 

UIAlertView iOS8 title set

ऐसा लगता है लेकिन है कि UIAlertView iOS 8 में पदावनत किया गया है: enter image description here

उत्तर

8

यह मेरे iOS 6 के बाद से UIAlertView के लिए initWithTitle:@"", UIActionSheet का उपयोग करने के लिए है क्योंकि मैं उस समय के दौरान एक डिजाइन मुद्दा का सामना करना पड़ रहा था जब मैं initWithTitle:nil उपयोग कर रहा था सबसे अच्छा अभ्यास किया गया है। मैंने वापस खोजने की कोशिश की, मुझे यह नहीं मिला कि वास्तव में क्या कारण है।

iOS 8 पर अपनी स्क्रीन शॉट से, मुझे लगता है कि आईओएस 8. के ​​लिए UIAlertView पर दृश्य पदानुक्रम का एक परिवर्तन मुझे लगता है कि Auto layout दृश्य hierarachy पर लागू किया जा सकता है और साथ ही आप messageLabel अप करने के लिए कूद देख सकते है शीर्षक लेबल।

मुझे यकीन नहीं है क्योंकि UIAlertView के लिए दृश्य पदानुक्रम निजी है।

UIAlertView क्लास का उपयोग किया जाना है और समर्थन उप-वर्गीकरण नहीं है। इस वर्ग के लिए दृश्य पदानुक्रम निजी है और संशोधित नहीं किया जाना चाहिए। आईओएस 7.1 पर

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

परिणाम: iOS 8 पर

<UIAlertView: 0x7fb3c05535b0; frame = (18 263; 284 62); opaque = NO; layer = <CALayer: 0x7fb3c0519810>> 

परिणाम -:

देखें: https://developer.apple.com/library/ios/documentation/uikit/reference/UIAlertView_Class/UIAlertView/UIAlertView.html

लेकिन, मुझे कोड का उपयोग करें।0:

<UIAlertView: 0x7bf64840; frame = (0 0; 0 0); layer = <CALayer: 0x7bf648f0>> 

मुझे यकीन है कि क्यों iOS 8 के लिए UIAlertView फ्रेम है नहीं कर रहा हूँ (0 0; 0 0);

तरह माइक ने कहा, मुझे लगता है कि आप

11

निकटतम मैं आईओएस 8 के साथ मिल सकता है संदेश के बजाय शीर्षक की स्थापना करके था और, यदि आप आईओएस 7 और आईओएस 8 के लिए अलग कोड पथ का उपयोग करने जा रहे हैं, तो आपको UIAlertController का उपयोग करना चाहिए:

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Location field required." message:nil preferredStyle:UIAlertControllerStyleAlert]; 
[alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { 
    [self dismissViewControllerAnimated:YES completion:nil]; 
}]]; 

[self presentViewController:alert animated:YES completion:nil]; 

मुझे दोनों विधियों के साथ एक ही परिणाम मिला।

4

आईओएस 8. के ​​लिए UIAlertController उपयोग करने के लिए मैं से मोटे अक्षरों के बिना सभ्य संदेश संरेखण पाने में कामयाब रहे सीखना चाहिए:

  1. @ करने के लिए शीर्षक की स्थापना " "शून्य के बजाय, और
  2. (यदि आईओएस 8) संदेश के सामने" \ n "प्रीपेड करता है।
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" 
            message:@"\nLocation field required." 
            delegate:nil 
            cancelButtonTitle:@"OK" 
            otherButtonTitles:nil]; 

enter image description here

1

इस कोड का प्रयास करें। यह मेरी तरफ xcode संस्करण 9.2

UIAlertController * alert= [UIAlertController 
           alertControllerWithTitle:nil 
           message:nil 
           preferredStyle:UIAlertControllerStyleActionSheet]; 
UIAlertAction* btn1 = [UIAlertAction 
         actionWithTitle:@"OKAY" 
         style:UIAlertActionStyleDefault 
         handler:^(UIAlertAction * action) 
         { 

         }]; 

[self presentViewController:alert animated:YES completion:nil]; 
पर काम कर रहा है