这应该很简单.
我有一个带有TableView的iPhone应用程序.如何将小经典箭头添加到每个单元格的右侧?
我有一个UITableView填充了可变高度的单元格.当视图被推入视图时,我希望表格滚动到底部.
我目前有以下功能
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[log count]-1 inSection:0];
[self.table scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:NO];
Run Code Online (Sandbox Code Playgroud)
log是一个可变数组,包含构成每个单元格内容的对象.
上面的代码工作正常viewDidAppear但是这有一个不幸的副作用,当视图首次出现然后跳到底部时显示表的顶部.如果table view可以在它出现之前滚动到底部我更喜欢它.
我试图滚动中viewWillAppear和viewDidLoad,但在数据尚未加载到表并且都抛出一个异常,这两种情况.
任何指导都会非常感激,即使只是告诉我我所拥有的一切都是可能的.
有人可以告诉我最简单的方法来更改UITableView部分标题中文本的字体大小吗?
我使用以下方法实现了部分标题:
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
Run Code Online (Sandbox Code Playgroud)
然后,我了解如何使用此方法成功更改节标题高度:
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
Run Code Online (Sandbox Code Playgroud)
我使用此方法填充了UITableView单元格:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)
但是,我不知道如何实际增加部分标题文本的字体大小 - 或者字体样式?
有人可以帮忙吗?谢谢.
我UITableView只有在iOS 7中有一些奇怪的问题.
UITableViewCellSeparator消失在第一行上方和最后一行下方.有时在选择行或某些滚动操作后会出现.
在我的情况下tableView是从Storyboard带UITableViewStylePlain样式加载.问题肯定不在UITableViewCellSeparatorStyle,默认情况下没有改变UITableViewCellSeparatorStyleSingleLine.
正如我在Apple Dev论坛上所读到的(这里和这里),其他人有这样的问题,并找到了一些解决方法,例如:
Workaround: disable the default selection and recreate the behaviour in a method
trigged by a tapGestureRecognizer.
Run Code Online (Sandbox Code Playgroud)
但我仍在寻找这种分隔符奇怪行为的原因.
有任何想法吗?
更新:正如我在XCode 5.1 DP和iOS 7.1 beta中看到的那样,Apple试图解决这个问题.现在,在一些刷新之后,有时需要在最后一行的下方显示分隔符,但不是在创建tableview之后.
当我backgroundColor为我设置UITableView它在iPhone(设备和模拟器)上工作正常但不在iPad模拟器上.相反,我得到了我设置的任何颜色的浅灰色背景groupTableViewBackgroundColor.
重现步骤:
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor blackColor];
}Run Code Online (Sandbox Code Playgroud)谢谢你的帮助!
UITableView 设置为静态单元格.
是否有可能以编程方式隐藏一些单元格?
我正在尝试从笔尖创建自定义表格视图单元格.我在这里指的是这篇文章.我面临两个问题.
我创建了一个.xib文件,其中拖动了一个UITableViewCell对象.我创建了一个子类,UITableViewCell并将其设置为单元格的类,将Cell设置为可重用的标识符.
import UIKit
class CustomOneCell: UITableViewCell {
@IBOutlet weak var middleLabel: UILabel!
@IBOutlet weak var leftLabel: UILabel!
@IBOutlet weak var rightLabel: UILabel!
required init(coder aDecoder: NSCoder!) {
super.init(coder: aDecoder)
}
override init(style: UITableViewCellStyle, reuseIdentifier: String!) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
}
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
Run Code Online (Sandbox Code Playgroud)
在UITableViewController中我有这个代码,
import UIKit …Run Code Online (Sandbox Code Playgroud) 我想知道如何改变UITableViewCell任何想法的蓝色突出显示/选择颜色?
在我的应用程序中,当我开始滚动UITableView时,我想隐藏键盘.我在互联网上搜索这个,大多数答案是子类化UITableView(http://stackoverflow.com/questions/3499810/tapping-a-uiscrollview-to-hide-the-keyboard).
我做了子类但它不起作用.
#import <UIKit/UIKit.h>
@protocol MyUITableViewDelegate <NSObject>
@optional
- (void)myUITableViewTouchesBegan;
@end
@interface MyUITableView : UITableView <UITableViewDelegate, UIScrollViewDelegate> {
id<MyUITableViewDelegate> delegate;
}
@end
Run Code Online (Sandbox Code Playgroud)
.m文件
#import "MyUITableView.h"
@implementation MyUITableView
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
NSLog(@"delegate scrollView"); //this is dont'work
[super scrollViewDidScroll:scrollView];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"delegate myUITableViewTouchesBegan"); // work only here
[delegate myUITableViewTouchesBegan];
[super touchesBegan:touches withEvent:event];
}
- (void)dealloc {
...
Run Code Online (Sandbox Code Playgroud)
我像这样使用这个类.但委托函数myUITableViewTouchesBegan在ViewController中不起作用
.H
#import <UIKit/UIKit.h>
#import "MyUITableView.h"
@interface FirstViewController : UIViewController <UITableViewDelegate, UISearchBarDelegate, MyUITableViewDelegate> {
MyUITableView *myTableView;
UISearchBar *searchBar;
}
@property(nonatomic,retain) …Run Code Online (Sandbox Code Playgroud) 我觉得这可能是一个普遍的问题,并且想知道是否有任何共同的解决方案.
基本上,我的UITableView具有每个单元格的动态单元格高度.如果我不在UITableView和我的顶部tableView.reloadData(),向上滚动变得有点跳跃.
我相信这是因为我重新加载数据,因为我正在向上滚动,UITableView会重新计算每个进入可见性的单元格的高度.如何缓解这种情况,或者如何仅将数据从某个IndexPath重新加载到UITableView的末尾?
此外,当我设法一直滚动到顶部时,我可以向下滚动然后向上滚动,没有跳跃没问题.这很可能是因为已经计算了UITableViewCell高度.
uitableview ×10
ios ×9
objective-c ×5
cocoa-touch ×3
swift ×3
autolayout ×1
ios8 ×1
ipad ×1
iphone ×1
keyboard ×1
scroll ×1
uikit ×1