iOS5 更新后,我的应用程序现在发生了一件奇怪的事情。
我有一个 UIPickerView 并使用 [customPickerView selectedRowInComponent:0]
获取选择的组件。用户选择第二行(索引为 1)
所以它看起来像:
i = [customPickerView selectedRowInComponent:0]; // -> i is 1 here, is OK!
[smsAgent sendSMS:smsTxt]; //just call another method to send a SMS
i
的值检查时没问题。现在我只需调用一个正常的短信对话
smsAgent
基本上看起来像这样:smsAgent...
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = delegate;
picker.recipients =[NSArray arrayWithObject: myTelNumber];
[delegate presentModalViewController:picker animated:YES];
当然不会对我的选择器做任何事情。
但是当这个“回归”在
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
[self dismissModalViewControllerAnimated:NO]; //take away the SMS screen fast, so we can send selectModeVCDidFinish to take away ourselves
int j = [customPickerView selectedRowInComponent:0];
[self.delegate selectModeVCDidFinish: selectedMode];
}
值 j 再次为 0,而不是 1 !
当然,customPickerView 没有任何 react ——我真的很困惑——这是怎么回事?
在升级到 iOS5 之前没有任何问题。
有什么我错过的吗?
非常感谢
最佳答案
感谢您详细解释问题。我的 UIPickerViews 有问题。正如我在上面的评论中提到的,我的代码基于 CustomPickerView - http://iphonedevelopment.blogspot.co.uk/2009/02/longer-spinning-blurring-v20.html
此代码与 5.0 版本不同。经过大量研究后,我发现 UIPicker 调用委托(delegate)函数的顺序/顺序不是问题。
但特别是非官方功能“scrollAnimationDuration”已被弃用且无法使用。这就是 UIPicker 不滚动更长时间的原因(就像它在 iOS 4.3.3 及更低版本中所做的那样)。
关于iphone - iOS5 中 UIPickerView 选择 RowInComponent 的不同奇怪行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7862550/