首先我已經以編程方式,而不是解決這個問題的佈局在故事板,因爲我已經通過編碼定義我的按鈕不拖&通過故事板下跌的,如何在標準UITableViewCell中以編程方式自動生成用於右側自定義UIButton的UITableViewCell。
我編程的通用iOS應用程序,我在其中很少有TableView的。我必須在每個UITableViewCell
右側添加一些自定義按鈕,或者您可以說我必須在單元格的邊緣添加按鈕,它在模擬器的iPhone7 Plus中工作得很好,但是其他的iPhone 5或5s其他功能的其他功能&其他iOS設備?這裏是它的外觀在iphone7加&的iPhone 5S
什麼樣的適度我應該在有關佈局的程序(代碼)做的,這裏是我的代碼在UITableViewCell
方法定義中的cellForRowAtIndexPath方法4個按鈕,
//Favorite Button
UIButton *addtoFavsButton = [UIButton buttonWithType:UIButtonTypeCustom];
[addtoFavsButton setImage:[UIImage imageNamed:@"like"] forState:UIControlStateNormal];
addtoFavsButton.frame = CGRectMake(370.0f, 0.0f, 50.0f, 45.0f);
[cell addSubview:addtoFavsButton];
[addtoFavsButton addTarget:self
action:@selector(addtoFavs:)
forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:addtoFavsButton];
[addtoFavsButton setTag:indexPath.row];
// WebView Button
UIButton *webViewButton = [UIButton buttonWithType:UIButtonTypeCustom];
[webViewButton setImage:[UIImage imageNamed:@"web"] forState:UIControlStateNormal];
webViewButton.frame = CGRectMake(335.0f, 0.0f, 50.0f, 50.0f);
[cell addSubview:webViewButton];
[webViewButton addTarget:self
action:@selector(webView:)
forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:webViewButton];
[webViewButton setTag:indexPath.row];
// Twitter Share Button
UIButton *twitterButton = [UIButton buttonWithType:UIButtonTypeCustom];
[twitterButton setImage:[UIImage imageNamed:@"twitter"] forState:UIControlStateNormal];
twitterButton.frame = CGRectMake(300.0f, 0.0f, 45.0f, 42.0f);
[cell addSubview:twitterButton];
[twitterButton addTarget:self action:@selector(twitterShare:event:) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:twitterButton];
//[twitterButton setTag:indexPath.row];
// Facebook Share Button
UIButton *facebookButton = [UIButton buttonWithType:UIButtonTypeCustom];
[facebookButton setImage:[UIImage imageNamed:@"facebook"] forState:UIControlStateNormal];
facebookButton.frame = CGRectMake(265.0f, 0.0f, 45.0f, 42.0f);
[cell addSubview:facebookButton];
[facebookButton addTarget:self
action:@selector(facebookShare:event:)
forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:facebookButton];
向我建議如何編程自動佈局這些按鈕,以便所有的按鈕都應該從任何iOS設備的右側開始調整。
我覺得沒有必要自動佈局的只是calcuate框架中的另一個按鈕基於設備寬度 –
我添加了我的答案 –