Instead of subclassing as suggested by others, you could also add your own subviews to the cell’s content view From Customizing Cells : If you want the cell to have different content components and to have these laid out in different locations, or if you want different behavioral characteristics for the cell, you have two alternatives. You can add subviews to the contentView property of the cell object or you can create a custom subclass of UITableViewCell You should add subviews to a cell’s content view when your content layout can be specified entirely with the appropriate autoresizing settings and when you don’t need to modify the default behavior of the cell You should create a custom subclass when your content requires custom layout code or when you need to change the default behavior of the cell, such as in response to editing mode See this example: define CUSTOM_IMAGE_TAG 99 #define MAIN_LABEL 98 // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UIImageView *customImageView = nil; UILabel *mainLabel = nil; UITableViewCell *cell = tableView dequeueReusableCellWithIdentifier:CellIdentifier; if (cell == nil) { cell = UITableViewCell alloc initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier autorelease; customImageView = UIImageView alloc initWithFrame:CGRectMake(0.0f, 0.0f, 40.0f, 40.0f) autorelease; customImageView.
Tag = CUSTOM_IMAGE_TAG; cell. ContentView addSubview:customImageView; mainLabel = UILabel alloc initWithFrame:CGRectMake(60.0f, 10.0f, 100.0f, 21.0f) autorelease; mainLabel. Tag = MAIN_LABEL; mainLabel.
NumberOfLines = 0; cell. ContentView addSubview:mainLabel; } else { customImageView = (UIImageView *)cell. ContentView viewWithTag:CUSTOM_IMAGE_TAG; mainLabel = (UILabel *)cell.
ContentView viewWithTag:MAIN_LABEL; } // Configure the cell. CGRect frame = mainLabel. Frame; frame.size.
Height = ... // dynamic height mainLabel. Frame = frame; return cell; } Obviously, you still need to implement tableView:heightForRowAtIndexPath.
Instead of subclassing as suggested by others, you could also add your own subviews to the cell’s content view. From Customizing Cells: If you want the cell to have different content components and to have these laid out in different locations, or if you want different behavioral characteristics for the cell, you have two alternatives. You can add subviews to the contentView property of the cell object or you can create a custom subclass of UITableViewCell.
You should add subviews to a cell’s content view when your content layout can be specified entirely with the appropriate autoresizing settings and when you don’t need to modify the default behavior of the cell. You should create a custom subclass when your content requires custom layout code or when you need to change the default behavior of the cell, such as in response to editing mode. See this example: #define CUSTOM_IMAGE_TAG 99 #define MAIN_LABEL 98 // Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UIImageView *customImageView = nil; UILabel *mainLabel = nil; UITableViewCell *cell = tableView dequeueReusableCellWithIdentifier:CellIdentifier; if (cell == nil) { cell = UITableViewCell alloc initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier autorelease; customImageView = UIImageView alloc initWithFrame:CGRectMake(0.0f, 0.0f, 40.0f, 40.0f) autorelease; customImageView. Tag = CUSTOM_IMAGE_TAG; cell. ContentView addSubview:customImageView; mainLabel = UILabel alloc initWithFrame:CGRectMake(60.0f, 10.0f, 100.0f, 21.0f) autorelease; mainLabel.
Tag = MAIN_LABEL; mainLabel. NumberOfLines = 0; cell. ContentView addSubview:mainLabel; } else { customImageView = (UIImageView *)cell.
ContentView viewWithTag:CUSTOM_IMAGE_TAG; mainLabel = (UILabel *)cell. ContentView viewWithTag:MAIN_LABEL; } // Configure the cell. CGRect frame = mainLabel.
Frame; frame.size. Height = ... // dynamic height mainLabel. Frame = frame; return cell; } Obviously, you still need to implement tableView:heightForRowAtIndexPath:.
The work of changing cell's subviews' frames is done in - (void)layoutSubviews of UITableViewCell class, so if you want alter that behavior you can subclass common UITableViewCell and then do smth like: @implementation MyTableViewCell - (void)layoutSubviews { super layoutSubviews; self.imageView. Frame = CGRectMake( -- your own size -- ); } @end.
– adit May 7 at 18:37 That is correct. You'll also need to change the frame of the textLabel as it will still behave as if the large imageView was still there. – jaminguy May 7 at 18:41 can you show me an example of the textLabel, as of now I think the UIImageView issue is fixed, but the layout of the textlabel is messy skitch.
Com/kuntul/r6fr8/ios-simulator – adit May 7 at 18:46.
I think the built in imageView will ignore your attempts to resize it. Subclass UITableViewCell and add your own custom UIImageView to it. Then you can control all aspects of your image view.
-- wisenomad's solution will work without having to add your own custom image view and labels. -- You will also have to change the frame of the textLabel. Here is an example.
- (void)layoutSubviews { super layoutSubviews; float sideLength = self.frame.size. Height; self.imageView. Frame = CGRectMake(0.0, 0.0, sideLength, sideLength); CGRect textLabelFrame = self.textLabel.
Frame; self.textLabel. Frame = CGRectMake(44.0, textLabelFrame.origin. Y, textLabelFrame.size.
Width - 44.0 + textLabelFrame.origin. X, textLabelFrame.size. Height); }.
I am getting something like this now skitch. Com/kuntul/r6fr8/ios-simulator – adit May 7 at 18:54 I changed my example slightly. Try out he new code.
Some of the views are over lapping which is causing your problems. – jaminguy May 7 at 19:40.
Subclass UITableViewCell and add your own custom UIImageView to it. Then you can control all aspects of your image view. -- wisenomad's solution will work without having to add your own custom image view and labels.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.