标签: tableview

uitableview reloadData问题

我一直在调试我的iPhone应用程序,发现了一些有趣的东西.

我有一个带TabBarcontroller的UIViewControllers(6个标签).每个选项卡都是一个UIViewController,它有一个UITtableview.viewDidLoad工作并带来初始数据.在UITableView上有一个搜索栏.在用户触摸按下搜索后,一些魔法发生,我得到一个包含数据的数组.我无法在tableview中看到新数据,并且[tableView reloadData]在viewDidLoad之外没有任何影响(第一次).

我可以看到保存数据的数组,dataSource设置为self.然而,没有显示数据!

所以我试过[self.tableView reloadData]和[self.tableView setNeedsDisplay]

有趣的是,新数据没有显示出来.但是,如果我向上或向下移动表,则会触发cellForRowAtIndexPath并且第一行显示数据.

任何人都可以对这个谜团有所了解吗?

如果有[self.view刷新屏幕] ??

-(void) viewWillAppear:(BOOL)animated{
    [self.tableView reloadData];
    [super viewWillAppear:animated];    
}

- (void) searchBarSearchButtonClicked:(UISearchBar *)searchBar2 {   
    [self searchForFullNames];
        //NSAssert(tableView, @"Whoops, tableView is Null");
    [tableView reloadData];
        // hide keyboard
    [searchBar2 resignFirstResponder];
}
- (void)viewDidLoad {

    NSString *path = [[NSBundle mainBundle] pathForResource:@"search" ofType:@"plist"];
    NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithContentsOfFile:path];  
    self.names = dict;
    [dict release];
    NSArray *array = [[names allKeys] sortedArrayUsingSelector:@selector(compare:)];
    self.keys = array;
    isSearchOn = NO;
    canSelectRow = NO;

    self.tableView.scrollEnabled = NO;

    [super viewDidLoad];
} …
Run Code Online (Sandbox Code Playgroud)

iphone uitableview uiviewcontroller uisearchbar tableview

1
推荐指数
1
解决办法
5752
查看次数

Facebook的iPhone应用程序 - 收件箱的用户界面

我试图弄清楚实现一个Compose New Message视图,它的工作方式与Facebook iPhone应用程序的工作方式相同.它非常相似MFMailCompose,MFMessageCompose但两者都已经设置为搜索iPhone的联系人.Facebook的应用程序看起来完全相同,只是他们的Facebook朋友搜索.我可以UISearchBar通过显示a 来使用a 来基本上获得完全相同的功能UITableView,但我想知道Facebook应用程序是如何做到的,因为它看起来好一点.

iphone objective-c uitableview tableview

1
推荐指数
1
解决办法
356
查看次数

可以动态地使用numberOfSectionsInTableView吗?

我可以动态获得行数吗?我正在尝试删除tableView部分标题,我不知道如何...我已经教过一个解决方案是改变部分的数量.

现在我的numberOfSectionsInTableView看起来像:

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
        return 2;
}
Run Code Online (Sandbox Code Playgroud)

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    beTribesAppDelegate *appDelegate = [UIApplication sharedApplication].delegate;

    switch (section) {
        case 0:
            return [appDelegate.firstArray count];
        case 1:
            return [appDelegate.secondArray count];    
        default:
            return 0;
    }
}
Run Code Online (Sandbox Code Playgroud)

像这样设置标题部分:

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{ 
    sectionTitles = [[NSMutableArray alloc] init];

        [sectionTitles addObject:@"firstSection"];
        [sectionTitles addObject:@"secondSection"];
    NSString *sectionText = [sectionTitles objectAtIndex:section];
    return sectionText;
}
Run Code Online (Sandbox Code Playgroud)

iphone uitableview tableview ios5

1
推荐指数
1
解决办法
4336
查看次数

TableView不会输入willDisplayCell

我的目标是定义我自己的单元格样式,背景,字体和大小.我试试这个.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    ScreenListElements *currentScreenElement = [self.screenDefBuild.elementsToTableView objectAtIndex:indexPath.row];

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:currentScreenElement.objectName];

    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:currentScreenElement.objectName];

    }

    cell.textLabel.text = currentScreenElement.objectName;

    return cell;
}

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{  
cell.contentView.backgroundColor = [UIColor blackColor];
}
Run Code Online (Sandbox Code Playgroud)

我想更改单元格背景,但我的应用程序不会进入willDisplayCell方法.我宣布我的班级为:

@interface MyTableView : UIViewController  <UITableViewDataSource,NSCopying> {
}
Run Code Online (Sandbox Code Playgroud)

我还有别的吗?或许是一种更好的方式来声明自己的细胞风格.

iphone objective-c tableview ios

1
推荐指数
1
解决办法
9146
查看次数

在地址簿更新时收到通知

我试图从addressBook使用预定义的方法获得更新

ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, NULL);
ABAddressBookRegisterExternalChangeCallback(addressBook, addressBookChanged, self);

void addressBookChanged(ABAddressBookRef addressBook, CFDictionaryRef info, void *context)
{
    NSLog(@"AddressBook Changed");
    [self getContactsFromAddressBook];
}
Run Code Online (Sandbox Code Playgroud)

我在调用ABAddressBookRegisterExternalChangeCallback(addressBook, addressBookChanged, self);application:didFinishLaunchingWithOptions,然后我做回调方法,如何在c方法中使用self?如果我不能使用我的对象,我怎么能更新我的tableview?

addressbook tableview ios

1
推荐指数
1
解决办法
1722
查看次数

向JavaFx tableView添加一个简单行

我是新手,TableView并在JavaFx中自定义它.我已经完成了很多教程,我已经了解了一些,但是在我的表中添加了行.例如,我有一个名为的表Table1.根据我的理解,我可以创建列ArrayList和:

for (int i = 0; i <= columnlist.size() - 1; i++) {
    TableView col = new TableView(columnlist.get(i));
    Table1.getColumns().add(col);
}
Run Code Online (Sandbox Code Playgroud)

现在我该如何为此添加一行?如果你能给我一个非常简单的例子,我会很感激,因为我已经通过其他例子,但它们太复杂了:)

java javafx row tableview

1
推荐指数
1
解决办法
2万
查看次数

JavaFX:一个TableColumn中有两个值

我有追随者http://code.makery.ch/library/javafx-8-tutorial/part2/,并且在TableColumn中使用lambdas进行了代码设置:

firstNameColumn.setCellValueFactory(cellData -> cellData.getValue().firstNameProperty());
lastNameColumn.setCellValueFactory(cellData -> cellData.getValue().lastNameProperty());
Run Code Online (Sandbox Code Playgroud)

但是,如果我有一列fullName并想将firstNameColumn和lastNameColumn合并为一个fullName怎么办?

谢谢你的回答。

java lambda javafx tableview

1
推荐指数
1
解决办法
560
查看次数

Xcode 9.0.1中的UITableView Swift 4单元格大小在运行时没有扩展.

这是一个故事板图像.我已经尝试了一个动态的tableviewcell我已经尝试过拖放并UITableViewCell从故事板中更改行高,它不能在运行时扩展单元格高度.

Xcode 9.0.1Swift 4,我面临的问题是细胞高度在运行时没有增加.所以,请帮助我解决这个问题.

在此输入图像描述

在此输入图像描述

row-height uitableview tableview ios swift

1
推荐指数
1
解决办法
4517
查看次数

Xcode - 自定义TableViewCell显示错误的数据

我试图在Storyboard中创建一个自定义的TableView Cell.加载ViewController时显示正确的数据.但是,当我开始来回滚动时,数据显示在随机单元格中,而不是在正确的位置.我还试图以编程方式将Right Detail单元格的文本粗体化为:

        if dayOfWeek!-1 == indexPath.row {
        cell.textLabel?.font = UIFont.boldSystemFont(ofSize: (cell.textLabel?.font.pointSize)!)
        cell.detailTextLabel?.font = UIFont.boldSystemFont(ofSize: (cell.detailTextLabel?.font.pointSize)!)
    }
Run Code Online (Sandbox Code Playgroud)

然而,类似的事情发生了:粗体看起来正确,文本在随机单元格中加粗.知道如何解决这个问题吗?谢谢!

xcode uitableview tableview ios swift

1
推荐指数
1
解决办法
385
查看次数

Flutter如何在ListTile中使用文本字段?

我想实现一个ListTile,它的尾部是一个文本字段,这类似于iOS静态tableview,以便用户可以单击它并直接编辑文本。无论如何,如何在Flutter中执行此操作?

layout textfield tableview dart flutter

1
推荐指数
1
解决办法
2589
查看次数