आईफोन (आईओएस 4.2) पर यूआईएक्शनशीट का उपयोग करते समय मुझे एक अजीब समस्या मिली है। इस कोड पर विचार करें:6 से अधिक कस्टम बटन का उपयोग करते समय UIActionSheet बटन इंडेक्स मान दोषपूर्ण?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self.window addSubview:viewController.view];
[self.window makeKeyAndVisible];
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:@"TestSheet"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles: nil];
[actionSheet addButtonWithTitle:@"one"];
[actionSheet addButtonWithTitle:@"two"];
[actionSheet addButtonWithTitle:@"three"];
[actionSheet addButtonWithTitle:@"four"];
[actionSheet addButtonWithTitle:@"five"];
[actionSheet addButtonWithTitle:@"six"];
//uncomment next line to see the problem in action
//[actionSheet addButtonWithTitle:@"seven"];
[actionSheet showInView:window];
[actionSheet release];
return YES;
}
- (void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
NSLog(@"buttonIndex: %d, cancelButtonIndex: %d, firstOtherButtonIndex: %d",
buttonIndex,
actionSheet.cancelButtonIndex,
actionSheet.firstOtherButtonIndex);
}
यदि आप इस एप्लिकेशन को प्रारंभ करते हैं, तो कार्यपत्रक अपेक्षित व्यवहार करता है। इसका मतलब है कि रद्द करें बटनऑनएक्स हमेशा 0 है, और बटन इंडेक्स सही ढंग से रिपोर्ट किए जाते हैं। बटन "एक" के लिए 1 और इसी तरह। यदि आप सातवें बटन जोड़ने के लिए लाइन में टिप्पणी करते हैं, तो एक्शनशीट एक अतिरिक्त लाइन पर रद्द बटन के साथ, एक प्रकार का टेबलव्यू उत्पन्न करता है। अगर मैं इस मामले में "एक" बटन दबाता हूं, तो बटनइंडेक्स वैरिएबल 0 है, लेकिन रद्द है बटन बटन। यह बताना असंभव है कि उपयोगकर्ता ने "रद्द करें" या "एक" बटन टैप किया है या नहीं। ऐसा लगता है कि यह इस तरह से होना चाहिए। क्या कोई असहमत है? आपकी सहायता के लिए धन्यवाद.
एक्शन शीट पर छह बटन? वास्तव में? मैं विकल्प के लिए एक टेबल का उपयोग करने का सुझाव देना चाहूंगा ... – Eimantas
अच्छी तरह से एक वर्कशीट होने का क्या मतलब है जो स्क्रॉलव्यू में 6 से अधिक बटन संभाल सकता है यदि आप इसका उपयोग नहीं करना चाहते हैं? – huesforalice
एक ही समस्या थी, यह एक बग स्पष्ट रूप से –