English 中文(简体)
• 说明Index公司的宽度,在UITableView右侧展示?
原标题:Set the width of the SectionIndex displaying on the right side of the UITableView?

我们怎么能够具体说明Indexes公司展示的宽度。 我的图像显示如下,将解释我的状况。

Image with UITableView sorted by Index along with it

I want to wrap the words within the sectionIndex and it is possible when SectionIndex frame size is fixed so I want to set the width of the SectionIndex Frame as displayed on the right side.SectionIndex frame automatically resizes according to the word length within it.

我写了该守则,以便把IndexTitle编成如下文:

NSMutableArray *array = [[NSMutableArray alloc] init];

for (int i = 0; i <[keys count]; i++) {
    NSString *str = [self.keys objectAtIndex:i];
    int length = [str length];
    if (length > 9) {
        str = [NSString stringWithFormat:@"%@..",[str substringToIndex:8]];
    }
       [array addObject:str];
}


NSArray *a =[NSArray arrayWithArray:array];
[array release];

return a;

请就此帮助我!

问题回答

不幸的是,不可能利用公共宣传工具来定制该部分指数。

如果这一特征对你来说如此重要,你可能会最终形成一个习俗科指数观点。

我最近也存在类似的问题,我没有时间整合一个习俗部分指数。 因此,我简单地修改了该部分指数表中的第一个项目,其位置是:

-(NSArray<NSString *> *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
    return @[@"      A      ", @"B", @"C", @"D", @"E", @"F"];
}

-(NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
{
    if ([title containsString:@"A"])
    {
        title = @"A";
    }
    //Your code here
}

A. 解决办法 我要求修改该节指数的宽度!

希望:

似乎在iPad和5方面做得很好。 将其用在电池组。

let rightOffset: CGFloat = cell.frame.width - cell.contentView.frame.width




相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签