I am writing a geometry based app. At one point in the app, there will be a UITB view with some custom rooms. These cells are involved UILabels in the text of these labels, I want to insert symbols at these two triangles:
However, since I do not find these symbols in any Apple font, is there a way to insert an image in the string instead of a symbol?
Here's a real idea of what I'm going to do ( too ) (the actual table will not be static): OK, I find what you're trying to do, the key, I think, keep adding controls to your cell, keep walking along with the calculation of the width. First of all, I suggest a data structure to capture the content of my cell. A simple array will work. I usually do this stuff as an Ivor: Then fill this array with the text and images you want. I am doing a line, but you can repeat for every line you need. And then, you need to create your cell: This yield:
@interface labelWith images viewer () {NSMutableArray * _cells; } @end
- (zero) viewDidoadload {[Super Viewedload]; _cells = [[NSMutableArray alloc] init]; [_cells addObject: [[NSArray alloc] initWithObjects: [UIImage imageNamed: @ "triangle.png"], @ "Cat", [UIImage imageNamed: @ "semiequal.png"], [UIImage imageNamed: @ "triangle.png" ], @ "Dog", @ "if", [UIImage imageNamed: @ "triangle1.png"], @ "then", [UIImage imageNamed: @ "triangle2.png"], zero]]; }
- (NSInteger) tableView: (UITableView *) tableView numberOfRowsInSection: (NSInteger) section { // Return the number of rows in the section Return _cells.count; } #define kEquationTag 100 #define kCellHeight 44 - (UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath {static NSString * CellIdentifier = @ "equationCell"; UITableViewCell * cell = [tableview] dequeueReusableCellWithIdentifier: CellIdentifier]; UIView * EquationContactor; If (cell == null) {// If we do not have such a cell to make it, the frame to hold our custom storage cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: CellIdentifier]; Equation Controller = [[UIView Alloc] initWithFrame: cell.contentView.bounds]; EquationContainer.tag = kEquationTag; [Cell.contentView addSubview: equationContainer]; } Else {// If we want to delete one already exists, get rid of the old custom accessories equation container = [cell.contentViewViewTag: kEquationTag]; (See the view in the UIView * equation). [[View viewFromSuperview]; }} // Configure Cell ... NSArray * Cell Contents = [_cells ObjectAutandx: IndexPath.ro]; NSUInteger x = 0; UIFont * font = [UIFont system fontoff size: 12.0]; (For NSObject * obC in cellContents) {if ([obj isKindOfClass: [NSString class]]) {NSString * text = (NSString *) obj; CGSize size = [text size fonts: font]; UILabel * label = [[UILabel alloc] initWithFrame: CGRectMake (x, (KCilHite - Size.) / 2.0.0, width, size, height]]; Label.text = text; Label.font = font; [Adding EquationContentSubview: Labels]; X + = size.width; } And if ([obj iskind of class: [UIImage class]]) {UIImage * image = (UIImage *) obj; UIImageView * imageView = [[UIImageView alloc] initWithFrame: CGRectMake (X, (kCellHeight - image.size.height) / 2.0, image.size.width, image.size.height)]; ImageView.image = Image; [Adding SamacharyCleanviewview: ImageView]; X + = image.size.width; }} Return Cell; }
Comments
Post a Comment