Why my button in a UItableView didn't respond? - uitableview

I've a UItableView with multiple section, In Each section, I've a View which contains a button, and in each of these sections one row is located but I've hided that row.
In short, my tableview is a collection of sections which in turns contains buttons on each section, when I click on the button it didn't respond but once I scroll ,my table from bottom to top the buttons are responded. What is the issue here?
Thanks!
Here is the code:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
sheettable.scrollsToTop=YES;
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 22)];
CGRect rect= CGRectMake(0, 0, 320,40);
UIBezierPath *maskPath;
maskPath = [UIBezierPath bezierPathWithRoundedRect:rect byRoundingCorners:(UIRectCornerAllCorners) cornerRadii:CGSizeMake(5.0, 5.0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame =rect;
maskLayer.path = maskPath.CGPath;
headerView.layer.mask = maskLayer;
headerView.backgroundColor=[UIColor greenColor];
UITextField *label1 = [[UITextField alloc] init] ;
label1.delegate=self;
label1.frame = CGRectMake(5, 1, 200, 35);
label1.font = [UIFont boldSystemFontOfSize:16];
label1.text = [[result2 objectAtIndex:section] objectForKey:#"cat_desc"];
UIButton *btn=[[UIButton alloc]init];
btn.frame=CGRectMake(5, 1, 200, 35);
btn.tag=section;
btn.backgroundColor=[UIColor clearColor];
[headerView addSubview:label1];
[btn addTarget:self action:#selector(selectedsections) forControlEvents:UIControlEventTouchUpInside];
[headerView addSubview:btn];
cameracategory=section;
return headerView;
}
-(void)selectedsections
{
if(cameracategory==0)
{
NSLog(#"At Index");
}
if(cameracategory==1)
{
NSLog(#"At Index");
}
if(cameracategory==2)
{
NSLog(#"At Index");
}
if(cameracategory==3)
{
NSLog(#"At Index");
}
if(cameracategory==4)
{
NSLog(#"At Index");
}
}

I tested your code, it works, but I created the UITableView myself. You should check that. Also try to write more readable code :) it will be more easier in the future :)
You have some misaligned frames (subviews are bigger than parent).
- (void)sectionButtonAction:(UIButton *)sender {
NSLog(#"Section button tapped: %i", sender.tag);
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
CGRect tableRect = tableView.frame;
CGRect headerRect = CGRectZero;
headerRect.size.width = tableRect.size.width;
headerRect.size.height = 22;
CGRect bezierRect = CGRectZero;
bezierRect.size.width = tableRect.size.width;
bezierRect.size.height = 44;
CAShapeLayer *maskLayer = [CAShapeLayer layer];
[maskLayer setFrame:bezierRect];
[maskLayer setPath:[UIBezierPath bezierPathWithRoundedRect:bezierRect byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(5, 5)].CGPath];
UIView *headerView = [[UIView alloc] initWithFrame:headerRect];
[headerView setBackgroundColor:[UIColor greenColor]];
[[headerView layer] setMask:maskLayer];
CGRect labelRect = CGRectZero;
labelRect.origin.x = 5;
labelRect.origin.y = 1;
labelRect.size.width = 200;
labelRect.size.height = 35;
UILabel *headerLabel = [[UILabel alloc] initWithFrame:labelRect];
[headerLabel setFont:[UIFont boldSystemFontOfSize:16]];
[headerLabel setText:#"asd"];
[headerView addSubview:headerLabel];
CGRect buttonRect = labelRect;
UIButton *headerButton = [UIButton buttonWithType:UIButtonTypeCustom];
[headerButton setFrame:buttonRect];
[headerButton setTag:section];
[headerButton addTarget:self action:#selector(sectionButtonAction:) forControlEvents:UIControlEventTouchUpInside];
[headerView addSubview:headerButton];
return headerView;
}

Related

Unable to create section border in tableview and i want to represent the ui as per the attached image?

how to create section border in tableview and i want to represent the ui as per the attached image ? i displayed spaces between sections but cannot set the border line for section.
For this you need to add and import
#import <QuartzCore/QuartzCore.h>
After that follow below steps
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *section = [[UIView alloc]init];
section.frame = CGRectMake(0, 0, tableview.frame.size.width, height);
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageWithName:#"imageName"]];
imageView.frame = CGRectMake(0, 0, YOUR_WIDTH, YOUR_HEIGHT); //set your frame
[section addSubview:imageView];
labelSection = [[UILabel alloc]init];
labelSection.textAlignment = NSTextAlignmentLeft;
labelSection.frame = CGRectMake(10, 5, tableview.frame.size.width, 20);
[labelSection setBackgroundColor:[UIColor clearColor]];
[labelSection setFont:[UIFont boldSystemFontOfSize:15]];
NSString *name = #"section title";
labelSection.text = name;
[labelSection setTextColor:[UIColor blackColor]];
[section addSubview:labelSection];
section.layer.borderWidth = 2.0f;
section.layer.cornerRadius = 1.0f;
section.layer.masksToBounds = YES;
section.layer.borderColor=[UIColor lightGrayColor].CGColor;
return section;
}
If you want to set row height
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 44; //It default size.If you want to change to other size you can change.
//OR
// return 90; //Set to your needed size
}

Tableview not scrolling smooth with static data

I am using custom cell and headerView with static images and footerView but not scrolling as smoothly as it should scroll, it is getting stuck in middle and then scrolls........
Header
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
UIView *headerview = [[UIView alloc]init];
if (section == 2) {
headerview.frame = CGRectMake(0, 30, tableView.frame.size.width, 117);
Button = [[UIButton alloc]initWithFrame:CGRectMake(0, 18, headerview.frame.size.width, 100)];
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(5, 0, tableView.frame.size.width, 17)];
label.text = #"Siddharth and hiren Like this";
label.font = [UIFont systemFontOfSize:10];
label.textColor = [UIColor blackColor];
[headerview addSubview:label];
}
else
{
headerview.frame = CGRectMake(0, 0, tableView.frame.size.width, 100);
Button = [[UIButton alloc]initWithFrame:headerview.frame];
}
// sheap top left and top right
UIBezierPath *maskPath;
maskPath = [UIBezierPath bezierPathWithRoundedRect:headerview.bounds
byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)
cornerRadii:CGSizeMake(7.0, 7.0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
headerview.frame = headerview.bounds;
maskLayer.path = maskPath.CGPath;
headerview.layer.mask = maskLayer;
// shape for button bottom
headerview.backgroundColor = [UIColor whiteColor];
CALayer *bottomBorder = [CALayer layer];
bottomBorder.frame = CGRectMake(0.0f, 0, headerview.frame.size.width, 1);
bottomBorder.backgroundColor = [UIColor colorWithRed:217/255.0f green:217/255.0f blue:217/255.0f alpha:1].CGColor;
bottomBorder.shadowColor = [[UIColor blackColor] CGColor];
bottomBorder.shadowOpacity = 0.9f;
bottomBorder.shadowRadius = 0.3f;
[headerview.layer addSublayer:bottomBorder];
headerview.layer.shouldRasterize = YES;
// Button Imageview
UIImageView *buttonimg = [[UIImageView alloc]initWithFrame:Button.bounds];
buttonimg.image = [UIImage imageNamed:[_SecImgArray objectAtIndex:section]];
buttonimg.layer.shouldRasterize = YES;
[Button addSubview:buttonimg];
// imageview overlay
UIView *overlay = [[UIView alloc]initWithFrame:Button.bounds];
overlay.alpha = 0.3;
overlay.backgroundColor = [UIColor blackColor];
overlay.layer.shouldRasterize = YES;
[buttonimg addSubview:overlay];
[Button addTarget:self action:#selector(Expand: and:) forControlEvents:UIControlEventTouchUpInside];
Button.tag = section;
if ([[AllNewsdic objectForKey:#"posts"] count] == 0) {
[Button setTitle:[[[DownloadData objectForKey:#"posts"]objectAtIndex:section]objectForKey:#"title"] forState:UIControlStateNormal];
}
else
{
[Button setTitle:[[[AllNewsdic objectForKey:#"posts"]objectAtIndex:section]objectForKey:#"title"] forState:UIControlStateNormal];
}
[Button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
Button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
Button.contentVerticalAlignment = UIControlContentVerticalAlignmentBottom;
Button.contentEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
Button.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
Button.titleLabel.numberOfLines = 0;
Button.titleLabel.font = [UIFont fontWithName:#"Avenir-Black" size:12];
Button.layer.shadowColor = [UIColor greenColor].CGColor;
Button.layer.shadowOpacity = 0.4;
Button.layer.shadowRadius = 1.0f;
Button.layer.cornerRadius = 7;
Button.layer.masksToBounds = YES;
Button.layer.shouldRasterize = YES;
[headerview addSubview:Button];
return headerview;}
Footer
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
UIView *fotter = [[UIView alloc]initWithFrame:CGRectMake(0, -10, tableView.frame.size.width, 30)];
fotter.backgroundColor = [UIColor whiteColor];
// corner redius
UIBezierPath *maskPath;
maskPath = [UIBezierPath bezierPathWithRoundedRect:fotter.bounds
byRoundingCorners:(UIRectCornerBottomLeft|UIRectCornerBottomRight)
cornerRadii:CGSizeMake(7.0, 7.0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
fotter.frame = fotter.bounds;
maskLayer.path = maskPath.CGPath;
// maskLayer.backgroundColor = [UIColor colorWithRed:217/255.0f green:217/255.0f blue:217/255.0f alpha:1].CGColor;
fotter.layer.mask = maskLayer;
// Bottom layer
CALayer *bottomBorder = [CALayer layer];
bottomBorder.frame = CGRectMake(0.0f, 32, fotter.frame.size.width, 2);
bottomBorder.backgroundColor = [UIColor blackColor].CGColor;
[fotter.layer addSublayer:bottomBorder];
// top Layer
CALayer *topLayer = [CALayer layer];
topLayer.frame = CGRectMake(13, 0, fotter.frame.size.width - 26, 0.7);
topLayer.backgroundColor = [UIColor colorWithRed:197/255.0f green:187/255.0f blue:188/255.0f alpha:1].CGColor;
topLayer.shadowOpacity = 0.6f;
topLayer.shadowRadius = 0.5f;
[fotter.layer addSublayer:topLayer];
// Like bUtton
likebutton = [[UIButton alloc]initWithFrame:CGRectMake(0, -3, fotter.frame.size.width/2, fotter.frame.size.height + 3)];
likebutton.titleLabel.font = [UIFont systemFontOfSize:10];
likebutton.titleLabel.tintColor = [UIColor colorWithRed:197/255.0f green:187/255.0f blue:188/255.0f alpha:1];
[likebutton addTarget:self action:#selector(like:) forControlEvents:UIControlEventTouchUpInside];
[likebutton setTitle:#"1 likes" forState:UIControlStateNormal];
likebutton.tag = section;
like = [[UIImageView alloc]initWithFrame:CGRectMake(40 ,8, 15, 15)];
like.image = [UIImage imageNamed:#"SimpleLike.png"];
[likebutton addSubview:like];
[likebutton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
[fotter addSubview:likebutton];
// Follow Button
NSLog(#"%f",fotter.frame.size.width/2 + 1);
follow = [[UIButton alloc]initWithFrame:CGRectMake(fotter.frame.size.width/2 , -3, fotter.frame.size.width/2, fotter.frame.size.height + 3)];
follow.titleLabel.font = [UIFont systemFontOfSize:10];
follow.titleLabel.tintColor = [UIColor colorWithRed:197/255.0f green:187/255.0f blue:188/255.0f alpha:1];
[follow setTitle:#"Follow" forState:UIControlStateNormal];
followimage = [[UIImageView alloc]initWithFrame:CGRectMake(35 ,8, 17, 17)];
followimage.image = [UIImage imageNamed:#"Follow.png"];
[follow addSubview:followimage];
[follow setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
follow.tag = section;
[follow addTarget:self action:#selector(Follow:) forControlEvents:UIControlEventTouchUpInside];
[fotter addSubview:follow];
return fotter;}
Cell
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
AllNewsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"AllNews"];
cell.one.text = [one objectAtIndex:indexPath.section];
cell.two.text = [two objectAtIndex:indexPath.section];
cell.three.text = [three objectAtIndex:indexPath.section];
[cell.three sizeToFit];
return cell;}
how to set tableview scroll smooth and effective
how to set interface properties
tableview data is static
Use reusable UITableViewCell inside function viewForHeaderInSection and inside viewForFooterInSection
Do not create the new UIView and buttons for each function call.
Your table view scrolling is not smooth because the views inside viewForHeaderInSection and viewForFooterInSection methods are allocated multiple times. Why ? Because whenever you scroll up and down, both the methods are called as and when required.
Check whether header view is already allocated. If it is nil, then and then allocate it and return it. Otherwise, just return it. Same way in case of footer view.
Add comment in case of any doubt..

Add loading footer on UITableView

I have a UITableView. When I scroll to the bottom it loads more data. How can I add a loading animation to the footer of the table when it´s scrolled to the bottom?
You can use MNMBottomPullToRefreshManager file to load more data. First you have to initialize it in viewDidLoad as
pullToRefreshManager_ = [[MNMBottomPullToRefreshManager alloc] initWithPullToRefreshViewHeight:60.0f tableView:table withClient:self];
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
[pullToRefreshManager_ tableViewScrolled];
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate: (BOOL)decelerate
{
[pullToRefreshManager_ tableViewReleased];
}
- (void)bottomPullToRefreshTriggered:(MNMBottomPullToRefreshManager *)manager
{
//method to get more data
// [self CallWebServiceToLoadMorePAYMENTS];
}
}
After reloading your tableView call:
[pullToRefreshManager_ tableViewReloadFinished];
Try this
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
UIView *headerView = [[[UIView alloc] init]autorelease];
[headerView setBackgroundColor:[UIColor clearColor]];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:#selector(aMethod:)
forControlEvents:UIControlEventTouchDown];
[button setTitle:#"Load More" forState:UIControlStateNormal];
button.frame = CGRectMake(10.0, 210.0, 160.0, 40.0);
[headerView addSubview:button];
return headerView;
}
Use this:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
if(array.count>1){
if(indexPath.row == array.count-1){
[self setupTableViewFooter];
}
}
}
- (void)setupTableViewFooter
{
// set up label
UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.navigationController.navigationBar.frame.size.height)];
footerView.backgroundColor = [UIColor clearColor];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
label.font = [UIFont fontWithName:Font_MuseoSans size:14];
label.autoresizingMask = UIViewAutoresizingFlexibleWidth;
label.textColor = [UIColor darkGrayColor];
label.text = #"Loading";
self.footerLabel = label;
CGSize labelSize = [self.footerLabel sizeThatFits:footerView.frame.size];
[footerView addSubview:self.footerLabel];
// set up activity indicator
UIActivityIndicatorView *activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
activityIndicatorView.hidesWhenStopped = YES;
activityIndicatorView.color = [UIColor blackColor];
self.activityIndicator = activityIndicatorView;
[self.activityIndicator startAnimating];
[footerView addSubview:self.activityIndicator];
CGRect footerFrame = footerView.frame;
label.frame = CGRectMake((footerFrame.size.width-labelSize.width - 4 - activityIndicatorView.frame.size.width)/2, (footerFrame.size.height-labelSize.height)/2
, (footerFrame.size.width-labelSize.width - 4 - activityIndicatorView.frame.size.width), labelSize.height);
self.activityIndicator.frame = CGRectMake(label.frame.origin.x + labelSize.width + 4, (footerFrame.size.height-activityIndicatorView.frame.size.height)/2
, activityIndicatorView.frame.size.width, activityIndicatorView.frame.size.height);
self.tableView.tableFooterView = footerView;
}

UiTableViewHeader - Dynamic button event handler

I need to add a uiButton to a static uitableview section header - I've made an attempt with the following -
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
// you can get the title you statically defined in the storyboard
NSString *sectionTitle = [self tableView:tableView titleForHeaderInSection:section];
CGRect frame = tableView.bounds;
// create and return a custom view
#define LABEL_PADDING 10.0f
HeaderLabelStyling *customLabel = [[HeaderLabelStyling alloc] initWithFrame:CGRectInset(frame, LABEL_PADDING, 0)] ;
UIButton *addButton = [[UIButton alloc] initWithFrame:CGRectMake(frame.size.width-60, 10, 50, 30)];
addButton.backgroundColor = [UIColor whiteColor];
addButton.titleLabel.textColor = [UIColor colorWithRed:240/255.0f green:118/255.0f blue:34/255.0f alpha:1.0f];
addButton.titleLabel.tintColor = [UIColor blackColor];
UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 100, 30)];
title.text = #"iawn";
customLabel.text = sectionTitle;
customLabel.backgroundColor= [UIColor colorWithRed:143.0f/255.0f green:137.0f/255.0f blue:135.0f/255.0f alpha:1.0f];
customLabel.textColor = [UIColor colorWithRed:255/255.0f green:255/255.0f blue:255/255.0f alpha:1.0f];
[customLabel addSubview:addButton];
[addButton addSubview:title];
[addButton addTarget:self action:#selector(receiverButtonClicked:) forControlEvents:UIControlEventTouchDown];
return customLabel;
}
-(void)receiverButtonClicked:(id)sender{
NSLog(#"button clicked");
}
the above adds a button - but doesn't react to the click event - can anyone suggest how I can get this to work?
UILabel does not handles touches by default.
Add following line of code:
customLabel.userInteractionsEnabled = YES;
In order to display button only for third section you should add following condition:
if(section == 2){...}
So your -tableView:viewForHeaderInSection: should look as follows:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection (NSInteger)section {
if(section != 2) return nil;
// you can get the title you statically defined in the storyboard
NSString *sectionTitle = [self tableView:tableView titleForHeaderInSection:section];
CGRect frame = tableView.bounds;
// create and return a custom view
#define LABEL_PADDING 10.0f
HeaderLabelStyling *customLabel = [[HeaderLabelStyling alloc] initWithFrame:CGRectInset(frame, LABEL_PADDING, 0)] ;
UIButton *addButton = [[UIButton alloc] initWithFrame:CGRectMake(frame.size.width-60, 10, 50, 30)];
addButton.backgroundColor = [UIColor whiteColor];
addButton.titleLabel.textColor = [UIColor colorWithRed:240/255.0f green:118/255.0f blue:34/255.0f alpha:1.0f];
addButton.titleLabel.tintColor = [UIColor blackColor];
UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 100, 30)];
title.text = #"iawn";
customLabel.text = sectionTitle;
customLabel.backgroundColor= [UIColor colorWithRed:143.0f/255.0f green:137.0f/255.0f blue:135.0f/255.0f alpha:1.0f];
customLabel.userInteractionsEnabled = YES;
customLabel.textColor = [UIColor colorWithRed:255/255.0f green:255/255.0f blue:255/255.0f alpha:1.0f];
[customLabel addSubview:addButton];
[addButton addSubview:title];
[addButton addTarget:self action:#selector(receiverButtonClicked:) forControlEvents:UIControlEventTouchDown];
return customLabel;
}

Header image not resizable in expandable table

I am pretty new to Xcode and this simple problem has been driving me mad! I have created an expandable table that works fine. This is some of the code on a UIView subclass for the section that expands when you tap on a cell:
- (id)initWithFrame:(CGRect)frame WithTitle: (NSString *) title Section:(NSInteger)sectionNumber delegate: (id <SectionView>) Delegate
{
self = [super initWithFrame:frame];
if (self) {
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(discButtonPressed:)];
[self addGestureRecognizer:tapGesture];
self.userInteractionEnabled = YES;
self.section = sectionNumber;
self.delegate = Delegate;
CGRect LabelFrame = CGRectMake(100, 100, 100, 100);
LabelFrame.size.width -= 100;
CGRectInset(LabelFrame, 1.0, 1.0);
//BUTTON
CGRect buttonFrame = CGRectMake(LabelFrame.size.width, 0, 100, LabelFrame.size.height);
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = buttonFrame;
//[button setImage:[UIImage imageNamed:#"carat.png"] forState:UIControlStateNormal];
//[button setImage:[UIImage imageNamed:#"carat-open.png"] forState:UIControlStateSelected];
[button addTarget:self action:#selector(discButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:button];
self.discButton = button;
//My IMAGE
NSString *imageName = #"gradient1.png";
UIImage *myImage = [UIImage imageNamed:imageName];
UIImageView *sectionHeaderView = [[UIImageView alloc] initWithImage:myImage];
UIImageView *imageView = [[UIImageView alloc] initWithImage:myImage];
imageView.frame = CGRectMake(20,50,100,100);
[self addSubview:sectionHeaderView];
self.headerBG = sectionHeaderView;
//HEADER LABEL
UILabel *label = [[UILabel alloc] initWithFrame: CGRectMake(22, 12, sectionHeaderView.frame.size.width, 35.0)];
label.textAlignment = NSTextAlignmentLeft;
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor whiteColor];
label.shadowColor = [UIColor darkGrayColor];
label.shadowOffset = CGSizeMake(0.0, -1.0);
label.text = title;
label.font = [UIFont fontWithName:#"AvenirNext-Bold" size:20.0];
sectionHeaderView.backgroundColor = [UIColor clearColor];
//label.textAlignment = UITextAlignmentLeft;
[self addSubview:label];
self.sectionTitle = label;
}
return self;
}
I have a custom image on the cell #"gradient1.png" but I don't seem to be able to resize it? Here is the header code in the UITableViewController:
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection: (NSInteger)section
{
SectionInfo *array = [self.sectionInfoArray objectAtIndex:section];
if (!array.sectionView)
{
NSString *title = array.category.name;
array.sectionView = [[SectionView alloc] initWithFrame:CGRectMake(0, 10, self.tableView.bounds.size.width, 0) WithTitle:title Section:section delegate:self];
}
return array.sectionView;
}
Sorry if this is a trivial question, your help is greatly appreciated!
I don't see where you are trying to resize the image so I can't offer any help in why it is not resizing, but I found this confusing:
//My IMAGE
NSString *imageName = #"gradient1.png";
UIImage *myImage = [UIImage imageNamed:imageName];
UIImageView *sectionHeaderView = [[UIImageView alloc] initWithImage:myImage];
UIImageView *imageView = [[UIImageView alloc] initWithImage:myImage];
imageView.frame = CGRectMake(20,50,100,100);
[self addSubview:sectionHeaderView];
self.headerBG = sectionHeaderView;
In this part of code you create two imageviews, then you resize one and add the other to the cell (I'm assuming cell) subviews. Is it possible that you are trying to resize the view that you never added as a subview of the cell?
Also, resizing should happen inside - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath.
Make sure that you are resizing the proper view, ten make sure you are resizing it in the proper place.

Resources