在我的应用中,我希望在方向改变时旋转图像,
为了做到这一点,我尝试了这段代码片段;
from django.db import models
# Create your models here.
class Teachers(models.Model):
teacher_name = models.CharField(max_length=255)
def __str__(self):
return self.teacher_name
class Students(models.Model):
teacher = models.ForeignKey(Teachers,related_name="students_teachers")
student_rollno = models.IntegerField()
student_name = models.CharField(max_length=255)
student_last_name = models.CharField(max_length=255)
def __str__(self):
return self.student_name
class Subjects(models.Model):
teacher = models.ForeignKey(Teachers,related_name="subjects_teachers")
student = models.ForeignKey(Students,related_name="subjects_students")
book_name = models.CharField(max_length=255)
book_description = models.CharField(max_length=255)
book_author = models.CharField(max_length=255)
def __str__(self):
return self.book_name
这样工作正常,但它只检查运行时的方向并根据图像的方向旋转图像,我需要实时检查设备的方向,并希望将图像旋转到横向模式设备是横向的,反之亦然。任何人都可以帮助我吗?提前谢谢。
答案 0 :(得分:1)
var maxDate = Math.max.apply(Math, obj.reportsArray.map(function (o)
{
return o.UpdatedDate.valueOf(); // <-- here you need the convertion of Date object
}))
答案 1 :(得分:0)
ON configuration changed u can detect like this; u will get a call back;
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Checks the orientation of the screen
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();
getImageOrientation();
rotateImage();
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
Toast.makeText(this, "portrait", Toast.LENGTH_SHORT).show();
getImageOrientation();
rotateImage();
}
}
答案 2 :(得分:0)
input