Search Results

Search found 2 results on 1 pages for 'partiallyfinite'.

Page 1/1 | 1 

  • Check if UINavigationItem title is truncated

    - by PartiallyFinite
    I want to check whether the title of a UINavigationItem is truncated. I set the title like this: self.navigationItem.title = whatever. I know I can check if the text in a UILabel is truncated like this: CGSize size = [label.text sizeWithFont:[UIFont fontWithName:@"myfont" size:18.0]]; if (size.width > label.bounds.size.width) { // set a shorter title } And I can even find the UINavigationItemView object in which the title is displayed like so: UIView *navItemView; for (UIView *view in self.navigationController.navigationBar.subviews) { if ([view isKindOfClass:NSClassFromString(@"UINavigationItemView")]) { navItemView = view; } } But I cannot apply this method to the navItemView because is always seems to have a width of exactly 58, which is much less than the title in it, so according to that, it would appear that the title is truncated, even when it isn't. So, my question comes down to this: How do I find the width of the title displayed in the UINavigationItem? UPDATE: I have found a solution to my problem, but it isn't exactly ideal, perfect, or reliable, so I am not marking it as an answer yet. If anyone has any better solutions, please share them.

    Read the article

  • NSFetchedResultsController sort different sections differently (ascending/descending)?

    - by PartiallyFinite
    In my app, I have a task list (no, it's not just another todo app), and I display the tasks in a UITableView using an NSFetchedResultsController. Here is the relevant initialisation code: NSSortDescriptor *dueDateSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"due" YES]; NSSortDescriptor *completionSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"completed" ascending:YES]; [fetchRequest setSortDescriptors:[NSArray arrayWithObjects:completionSortDescriptor, dueDateSortDescriptor, nil]]; _fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:context sectionNameKeyPath:@"completed" cacheName:nil]; What this does is sorts the tasks such that I have an incomplete tasks section at the top, sorting with the tasks due first on top, and tasks due later further down. This all works. However, this means that the second section, the one with the completed tasks, also sorts this way, so the earliest due tasks are on top. What I want to do is change it so the second section sorts the other way around (in descending order), but the first section stays sorted in ascending order. Is this even possible? How would I go about this? Why I want to do this: The way it currently works, the tasks at the top of the second section (and therefore the most visible) are the ones that were completed ages ago. It is more likely that the user would want to see the tasks that are more recently completed (and uncheck one if it was accidentally checked), and presumably the tasks with a more recent due date were more recently completed. I am happy to add a separate completion date field to the Core Data task object if necessary (This isn't a shipping application yet, so I can change the data format however I like).

    Read the article

1