我想根据变化方向,从方案上建立一个表格,并加以修改。 问题是,在一开始表时,不论方向如何,总是出现在同一个地点。
而I dont understad,为什么更新OnRotate语的方法第一次需要3次。
该法典分为一等,即国际律师联合会。
- (void)viewDidLoad {
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(updateViewOnRotate:)
name:UIDeviceOrientationDidChangeNotification
object:nil];
[super viewDidLoad];
}
-(void) updateViewOnRotate:(NSNotification *)notification {
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if ((orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight)) {
// present the other viewController, it s only viewable in landscape
[[self.view subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
// get rid of the landscape controller
UIView *opcionesView = [[[UIView alloc] initWithFrame:CGRectMake(100, 100, 250, self.view.frame.size.height)] autorelease];
opcionesView.backgroundColor = UIColor.redColor;
UITableView *table = [[[UITableView alloc] initWithFrame:CGRectMake(0, 50, 250, 500) style:UITableViewStylePlain] autorelease];
[opcionesView addSubview:table];
[self.view addSubview:opcionesView];
[self dismissModalViewControllerAnimated:YES];
}
else{
[[self.view subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
UIView *opcionesView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 250, self.view.frame.size.height)] autorelease];
opcionesView.backgroundColor = UIColor.redColor;
UITableView *table = [[[UITableView alloc] initWithFrame:CGRectMake(0, 50, 250, 500) style:UITableViewStylePlain] autorelease];
[opcionesView addSubview:table];
// UINavigationBar *b=[[[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, 250, 50)]autorelease];
// [opcionesView addSubview:b];
[self.view addSubview:opcionesView];
}
}