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. UIScrollViewにUIButtonを追加し、UIScrollViewをUIViewに追加します。
- 4. ipadでtableviewにカラムを追加する
- 5. グリッドにオーバーレイを追加するtableView
- 6. UIbuttonオプションボタンをスクロールビューに追加
- 7. JavaFXのTableViewの中に格付けを追加するには
- 8. UIScrollViewにUIButtonを追加する問題
- 9. UItableviewセルにUIButtonを追加する
- 10. iphone sdk:UIWebViewに追加されたUIButtonにイベントを追加する方法
- 11. UIViewContentModeAspectFitでUIButtonに画像を追加するには?
- 12. UIAlertViewにカスタムUIbuttonを追加するには?
- 13. ABTableViewCell - UIButtonを追加する
- 14. 項目をAddButton経由でTableViewに追加しましたか?
- 15. プログラムでTableViewセルに画像を追加
- 16. Moreボタンをクリックしたときにtableviewに画像を追加
- 17. グループ化されたテーブルビューのセルにUISwitchを追加するにはどうすればよいですか?
- 18. iPhoneのTableViewの行の右側に画像を追加するには?
- 19. UIButtonにオブザーバーを追加するにはどうすればよいですか?
- 20. 詳細ビューからTableViewに行を追加します
- 21. Iphone:別のテーブルビューのセルにTableviewを追加できますか
- 22. ボタンを押したときにTableViewセルに画像を追加する
- 23. スクロールするiphoneでtableviewに要素を追加する方法は?
- 24. uipickerをuibuttonと一緒にiphoneに追加する方法
- 25. UIButtonに選択アニメーションを追加します
- 26. 新しいUIButton "state"をカスタム画像に追加します。
- 27. カスタムビューでUIButtonにアクションを追加します。
- 28. IOSのtableViewに項目を追加する
- 29. iphoneのTableViewで動的に行を追加する
- 30. ObservableListからtableviewに画像を追加する