gpt4 book ai didi

ios - 无法在 tableViewCell 中设置横向坐标

转载 作者:行者123 更新时间:2023-11-29 03:22:43 25 4
gpt4 key购买 nike

如果我以横向模式启动应用程序,buttonListbuttonAttachment 的坐标将分配并设置为横向,旋转到纵向时坐标不会改变.

同样,如果我以纵向模式启动应用程序,buttonListbuttonAttachment 的坐标将分配并设置为纵向,其坐标在旋转时不会改变到景观。

我使用了自定义单元格并且未选中自动布局。我已经为按钮设置了标签,所以不能在自定义 tableViewCell 类中提及坐标。我该如何解决?这是我在 cellForRowAtIndexPath

中的代码
 //static NSString *cellId = @"collabId";
//emptyCell *cell = (emptyCell *)[self.tableViewJoined dequeueReusableCellWithIdentifier:cellId];

static NSString *cellId = Nil;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
cellId = @"collabIdPhone";
}
else
{
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if (orientation == UIDeviceOrientationPortrait)
{
cellId = @"collabIdIPadPortrait";
}
else
{
cellId = @"collabIdIPadLandscape";
}
}
emptyCell *cell = (emptyCell *)[self.tableViewJoined dequeueReusableCellWithIdentifier:cellId];
if(!cell)
{
NSArray *nib;
UIButton *buttonList;
UIButton *buttonAttachment;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
nib = [[NSBundle mainBundle] loadNibNamed:@"emptyCell" owner:self options:nil];
buttonList = [[UIButton alloc] initWithFrame:CGRectMake(199, 0, 30, 25)];
buttonAttachment = [[UIButton alloc] initWithFrame:CGRectMake(290, 0, 30, 25)];
}
else
{
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if (orientation == UIDeviceOrientationPortrait)
{
nib = [[NSBundle mainBundle] loadNibNamed:@"emptyCell_iPad" owner:self options:nil];
buttonList = [[UIButton alloc] initWithFrame:CGRectMake(452, 0, 62, 25)];
buttonAttachment = [[UIButton alloc] initWithFrame:CGRectMake(650, 0, 98, 25)];
NSLog(@"| | | |"); //not invoked when rotated from landscape to portrait
}
else
{
nib = [[NSBundle mainBundle] loadNibNamed:@"emptyCell_iPad_Landscape" owner:self options:nil];
buttonList = [[UIButton alloc] initWithFrame:CGRectMake(591, 0, 81, 24)];
buttonAttachment = [[UIButton alloc] initWithFrame:CGRectMake(850, 0, 128, 24)];
NSLog(@"- - - - -"); //not invoked when rotated from portrait to landscape
}
}

最佳答案

根据评论-

您如何管理方向变化(您实现了哪些通知、方法)?在发生方向更改后,您的 TableView 需要被告知reloadData

关于ios - 无法在 tableViewCell 中设置横向坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20881270/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com