我有这种情况:
我以编程方式创建内部带有标签的单元格(UIView),并正确设置scrollView的contentSize。
我知道
scrollView.setContentOffset(CGPoint(x: 0, y: 80.0), animated: true)
将滚动视图移动80。
我如何"覆盖"滚动视图行为,以便始终滚动80? 我想要的是某种挑选行为..这可能吗?
答案 0 :(得分:3)
布局更改时,您可以使用以下方法
func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
myScrollView.contentOffset.y += 80
}
答案 1 :(得分:1)
没有人正确回答这个问题,所以我通常会自己解决:
[HttpPost]
public ActionResult EditUserAccount_Save(UserAccountViewModel editUserAccountViewModel)
{
var errors = ModelState.Values.SelectMany(v => v.Errors);
if (ModelState.IsValid)
{
editUserAccountViewModel.UserName = UserSession.GetValue(StateNameEnum.UserName, StateNameEnum.UserName.ToString()) as string;
db_user user = new db_user();
user.Title = editUserAccountViewModel.Title;
user.FirstName = editUserAccountViewModel.FirstName;
user.LastName = editUserAccountViewModel.LastName;
user.PhoneNumber = editUserAccountViewModel.PhoneNumber;
user.AltPhoneNumber = editUserAccountViewModel.AltPhoneNumber;
user.EmailAddress = editUserAccountViewModel.EmailAddress;
user.LanguageId = context.languages.Where(t => t.Code == editUserAccountViewModel.Language).Select(t => t.Id).FirstOrDefault();
user.CreatedDate = DateTime.Now;
user.UserId = WebSecurity.GetUserId(editUserAccountViewModel.UserName);
context.Entry(user).State = EntityState.Modified;
context.SaveChanges();
JsonResult res = Json(new { Success = true, data = "", Message = "" });
return res;
}
JsonResult res2 = Json(new { Success = false, data = "", Message = "" });
return res2;
}
答案 2 :(得分:0)
可能是这样的: (你需要添加一些验证) 为您的滚动视图(UIScrollViewDelegate)创建一个委托类
现在在UIScrollViewDelegate中添加此函数
myScrollView.delegate = instanceOfUIScrollViewDelegate;
func scrollViewDidScroll(scrollView: UIScrollView) {
scrollView.contentOffset.y+=80;
}
答案 3 :(得分:0)
您可以使用此方法
scrollView.setContentOffset( CGPoint(x:0,y:30), animated:true )