UISwitchまたは他のコントローラのラベルをセクション化されたtableViewのフッター(またはヘッダー)に追加する方法を理解しようとしています。どんな助けでも大歓迎です。前もって感謝します!それを検索して働いた後、私は次のことをやったUIButtonまたはUISwitchをtableViewに追加するには:viewForFooterInSection
6
A
答えて
8
さて、:
// Need to refactor so that the label is Public Sharing and Priviate Sharing and the actions work for each switch
- (UIView *) tableView: (UITableView *) tableView
viewForFooterInSection: (NSInteger) section
{
if (section == 0 || section == 1) {
CGRect screenRect = [[UIScreen mainScreen] applicationFrame];
UIView* footerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, screenRect.size.width, 44.0)] autorelease];
footerView.autoresizesSubviews = YES;
footerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
footerView.userInteractionEnabled = YES;
footerView.hidden = NO;
footerView.multipleTouchEnabled = NO;
footerView.opaque = NO;
footerView.contentMode = UIViewContentModeScaleToFill;
// Add the label
UILabel* footerLabel = [[UILabel alloc] initWithFrame:CGRectMake(150.0, -5.0, 120.0, 45.0)];
footerLabel.backgroundColor = [UIColor clearColor];
footerLabel.opaque = NO;
footerLabel.text = @"Sharing";
footerLabel.textColor = [UIColor tableHeaderAndFooterColor];
footerLabel.highlightedTextColor = [UIColor tableHeaderAndFooterColor];
footerLabel.font = [UIFont boldSystemFontOfSize:17];
footerLabel.shadowColor = [UIColor whiteColor];
footerLabel.shadowOffset = CGSizeMake(0.0, 1.0);
[footerView addSubview: footerLabel];
[footerLabel release];
// Add the switch
UISwitch* footerSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(215.0, 5, 80.0, 45.0)];
[footerView addSubview: footerSwitch];
// Return the footerView
return footerView;
}
else return nil;
}
// Need to call to pad the footer height otherwise the footer collapses
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
switch (section) {
case 0:
case 1:
return 40.0;
default:
return 0.0;
}
}
私はこれが正しいであり、この場合に役立ちます誰がこれを投票してください願っています。乾杯!
0
は、私はあなたが私はそれに似たいくつかのコードを使用uiview-
0
を自動解放する必要があると思う...しかし、私は右のaddSubview後のNSLog()の呼び出しを追加しました。
私は私のtableViewをスクロールすると...私は次のようにメッセージの数百を取得:
> Adding another subview
> Adding another subview
> Adding another subview
> Adding another subview
> Adding another subview
> Adding another subview
は、正常ですか?私はただONEボタン、ONEビューで、私のTableViewの最下部にしたい。
関連する問題
- 1. UISwitchを有効にするCreat UIButton
- 2. UIButtonは、私はテーブルビューのセルにボタンを追加しました
- 3. TableViewでダイナミックUISwitchを使用するには?
- 4. UIScrollViewにUIButtonを追加し、UIScrollViewをUIViewに追加します。
- 5. UIbuttonオプションボタンをスクロールビューに追加
- 6. 配列にUIButtonを追加する
- 7. UIScrollViewにUIButtonを追加する問題
- 8. UItableviewセルにUIButtonを追加する
- 9. FXMLを使用してTableViewにボタンを追加するには?
- 10. ipadでtableviewにカラムを追加する
- 11. グリッドにオーバーレイを追加するtableView
- 12. .xibにTableViewを追加する
- 13. UIViewContentModeAspectFitでUIButtonに画像を追加するには?
- 14. UIAlertViewにカスタムUIbuttonを追加するには?
- 15. uibuttonをタップしたときにtableViewの下にスクロールする
- 16. iphone sdk:UIWebViewに追加されたUIButtonにイベントを追加する方法
- 17. JavaFXのTableViewの中に格付けを追加するには
- 18. tableViewコントローラにフローティングボタンを追加するには
- 19. qmlに編集可能なTableViewヘッダを追加するには?
- 20. ABTableViewCell - UIButtonを追加する
- 21. UIButtonのUITableViewに追加
- 22. スタイルサブタイトルのTableViewCellにUISwitchを追加します。
- 23. SwiftのtableViewSectionヘッダーにラベルとUIButtonを追加する方法は?
- 24. removefromsubview uibuttonの後にボタンのサブビューを追加する方法は?
- 25. カスタムテーブルビューセル内のUISwitchにオブザーバを追加する
- 26. 項目をAddButton経由でTableViewに追加しましたか?
- 27. グループ化されたテーブルビューのセルにUISwitchを追加するにはどうすればよいですか?
- 28. UIButtonに「前処理」を追加する方法はありますか?
- 29. UIButtonにプログラムでaddTargetアクションを追加
- 30. SwiftのUIButtonにシェイプを追加