[英]Control rotation
我有一個像pulse app的應用程序,一個水平的tableview。 我想在一個部分中顯示5行,但是我想控制它在橫向或縱向時的寬度,因此它可以適應屏幕。 我怎樣才能做到這一點?
旋轉設備時調整UITableView的大小。 像這樣:
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation duration:(NSTimeInterval)duration{
//Resize your UITableView, i.e.:
orientation = self.interfaceOrientation;
if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown)
{
myTable.frame = CGRectMake(x, y, width, height);
}
else
{
myTable.frame = CGRectMake(x, y, width, height);
}
[[self view] setNeedsDisplay];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown || interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.