我想这段代码转换为C#,代码是从苹果公司的documentation转换从obj获得C到C#
NSDictionary* info = [aNotification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, kbSize.height, 0.0);
scrollView.contentInset = contentInsets;
scrollView.scrollIndicatorInsets = contentInsets;
CGRect aRect = self.view.frame;
aRect.size.height -= kbSize.height;
if (!CGRectContainsPoint(aRect, activeField.frame.origin)) {
CGPoint scrollPoint = CGPointMake(0.0, activeField.frame.origin.y-kbSize.height);
[scrollView setContentOffset:scrollPoint animated:YES];
到目前为止,这是我的尝试,我被卡在CGRectValue。
NSDictionary info = n.UserInfo;
SizeF kbSize = ((RectangleF)info[UIKeyboard.FrameBeginUserInfoKey]).Size;
UIEdgeInsets contentInsets = new UIEdgeInsets(0.0f, 0.0f, kbSize.Height, 0.0f);
this.uiScrollView.ContentInset = contentInsets;
this.uiScrollView.ScrollIndicatorInsets = contentInsets;
RectangleF aRect = this.View.Frame;
aRect.Size.Height -= kbSize.Height;
if(!aRect.Contains(_currentField.Frame))
{
PointF scrollPoint = new PointF(0.0f, _currentField.Frame.Y - kbSize.Height);
this.uiScrollView.SetContentOffset(scrollPoint, true);
}
我可能没有使用正确的类型,有人可以帮助我,或一些替代代码做类似的事情。 感谢
我不确定你的意思是“我卡在CGRectValue”。调试器是否显示所有先前提到的变量都具有您期望的值?调试器在aRect = self.view.frame之后显示有关aRect的内容? – 2012-01-29 01:50:43
我无法将该行转换为C#代码。它不会编译。请参阅我尝试的C#代码。 – 2012-01-29 02:47:41
如何获得'_currentField'?我也在转换教程* [iOS SDK:从键盘下面保存内容](http://code.tutsplus.com/tutorials/ios-sdk-keeping-content-from-underneath-the-keyboard--mobile -6103)* ... – testing 2014-11-27 11:38:25