2011-11-21 117 views
0

我有一个应用程序,如脉冲应用程序,horizaontal tableview。我想在节中显示5行,但我想在横向或纵向时控制行的宽度,因此它会调整到屏幕。我怎么能做到这一点有没有办法做到这一点?控制旋转

回答

0

设备旋转时调整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); 
} 
+0

谢谢你的工作 – Alfonso