我有一個應用程序,我有一個側面菜單。在側面菜單中,按鈕的其餘部分顯示正常,但兩個按鈕拉伸很奇怪。附件截圖爲。爲什麼按鈕背景圖像會變形?
這是我如何設置按鈕圖像。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"SimpleTableItem";
RearViewTableViewCell *cell = [self.tableViewSideMenu dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if(cell == nil)
{
NSArray *cellView = [[NSBundle mainBundle] loadNibNamed:@"RearViewTableViewCell" owner:nil options:nil];
cell = (RearViewTableViewCell *)[cellView objectAtIndex:0];
cell.btnItemSelector.tag = indexPath.row;
[cell.btnItemSelector setBackgroundImage:[UIImage imageNamed:[buttonUnselect objectAtIndex:indexPath.row]] forState:UIControlStateNormal];
[cell.btnItemSelector setBackgroundImage:[UIImage imageNamed:[buttonSelect objectAtIndex:indexPath.row]] forState:UIControlStateHighlighted];
[cell.btnItemSelector addTarget:self action:@selector(btnMenuItemTapped:) forControlEvents:UIControlEventTouchUpInside];
cell.selectionStyle =UITableViewCellSelectionStyleNone;
}
return cell;
}
我是新的自適應佈局。它是否導致問題?在iphone 5s上運行良好,但在iphone 6上它描繪了這種行爲。我只向tableview添加了一個約束(寬度)。我在這裏使用的uitableviewcell(自定義)具有領先空間,垂直空間,中心對齊等的所有常規約束。任何想法?
更新:我設置背景色爲紅色,它原來的問題,這兩個按鈕被調整到更小的&可能較寬的視野。爲什麼會發生?
是否所有正在伸展的行都有文字和圖像?我的意思是設置你有圖像和文字。如果它只有圖像,則某些約束問題可能會導致問題。只是隨機的想法:) –
圖像之間的大小(寬度x高度)差異是什麼?如果我不得不猜測,我會說這兩張圖片的寬度不如其他圖片寬。 backgroundImages應該伸展,它們是按鈕的背景。 –
這只是圖像。沒有文字。按鈕的其餘部分使用相同的約束條件設置得很好 – NSNoob