2011-11-21 88 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