I have made an UITableView and I am fetching data from JSON from a webservice.
Firat, I want that I get first 5 objects first and load them in my tableView. That is happening properly.
Then I want that whenever the user scrolls to the footer ..the next 5 objects should be fetched and it should be shown in tableView..
I am stuck here ..can anyone give me any idea how to proceed next?
My tableview has all custom cells loading from the custom classes for different types?
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
if(section==[array count]-1)
{
UITableViewCell *cell = [self tableView:mtableview1 cellForRowAtIndexPath:myIP];
frame = cell.contentView.frame;
footerView = [[UIView alloc] init];
footerView.backgroundColor=[UIColor clearColor];
self.activityIndicator = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray] autorelease];
self.activityIndicator.hidesWhenStopped=YES;
self.activityIndicator.center = CGPointMake(65,50);
[self.activityIndicator startAnimating];
UILabel* loadingLabel = [[UILabel alloc]init];
loadingLabel.font=[UIFont boldSystemFontOfSize:12.0f];
loadingLabel.textAlignment = UITextAlignmentLeft;
loadingLabel.textColor = [UIColor colorWithRed:87.0/255.0 green:108.0/255.0 blue:137.0/255.0 alpha:1.0];
loadingLabel.numberOfLines = 0;
loadingLabel.text=#"Loading.......";
loadingLabel.frame=CGRectMake(95,35, 302,25);
loadingLabel.backgroundColor =[UIColor clearColor];
loadingLabel.adjustsFontSizeToFitWidth = NO;
[footerView addSubview:self.activityIndicator];
[footerView addSubview:loadingLabel];
[self performSelector:#selector(loadending) withObject:nil afterDelay:1.0];
[loadingLabel release];
NSLog(#"%f",mtableview1.contentOffset.y);
mtableview1.tableFooterView=footerView;
return footerView;
}
return nil;
}
I have been doing it like this, but its position is not correct all the time. That's my big issue.
You can use the below concept.Concept is when user pull the table view then reload the additional data like pull to refresh.
Code Sample :
//MARK: -UIScrollViewDelegate
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
if (scrollView.contentOffset.y <= - 65.0f) {
// fetch extra data & reload table view
}
}
Use UIScrollViewDelegate Methods
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
}
in scrollViewDidScroll Method you can check row index for call you loading method
NSIndexPath *indexPath = [[self.myTable indexPathsForVisibleRows]objectAtIndex:1]; //in middle visible of row
int visibleRowIndex = indexPath.row;
I already implement this please look this here is my code
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
if(footerView == nil)
{
footerView = [[UIView alloc] init];
CGRect screenBounds = [[UIScreen mainScreen] bounds];
if (ObjApp.checkDevice == 1)
{
UIImage *image = [[UIImage imageNamed:#"LoadMoreBtn.png"]
stretchableImageWithLeftCapWidth:8 topCapHeight:8];
btnLoadMore = [UIButton buttonWithType:UIButtonTypeCustom];
[btnLoadMore setBackgroundImage:image forState:UIControlStateNormal];
if(screenBounds.size.height == 568)
{
// iPhone 5
[btnLoadMore setFrame:CGRectMake(74, 13, 148, 34)];
}
else
{
// iPohne 4 and Older iPhones
[btnLoadMore setFrame:CGRectMake(74, 13, 148, 34)];
}
}
else if (ObjApp.checkDevice == 2)
{
UIImage *image = [[UIImage imageNamed:#"LoadMoreBtn_iPad.png"]
stretchableImageWithLeftCapWidth:8 topCapHeight:8];
btnLoadMore = [UIButton buttonWithType:UIButtonTypeCustom];
[btnLoadMore setBackgroundImage:image forState:UIControlStateNormal];
[btnLoadMore setFrame:CGRectMake(220, 26, 296, 67)];
}
[btnLoadMore.titleLabel setFont:[UIFont boldSystemFontOfSize:20]];
[btnLoadMore setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[btnLoadMore addTarget:self action:#selector(btnLoadmore_clicked:)
forControlEvents:UIControlEventTouchUpInside];
[footerView addSubview:btnLoadMore];
}
return footerView;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
if (ObjApp.checkDevice == 1)
{
return 47;
}
else
{
return 100;
}
return 0;
}
#pragma mark - Button Click Methods
-(void)btnLoadmore_clicked:(id)sender
{
if(page > 0)
{
sendpage++;
if(sendpage<= page)
{
[self loading];
NSString *urlString = [NSString stringWithFormat:#"data={\"name\":\"%#\",\"lat\":\"%f\",\"page\":\"%d\",\"long\":\"%f\"}",txtSearchFld.text,ObjApp.current_Latitude,sendpage,ObjApp.current_Longitude];
[WebAPIRequest WS_Search:self :urlString];
CGFloat height = tblSearchResult.contentSize.height - tblSearchResult.bounds.size.height;
[tblSearchResult setContentOffset:CGPointMake(0, height) animated:YES];
}
}
}
You can increase Number of rows In table View when you reach to the last row check do you have more content to show or not. If u have MOre content to show then increase number of rows.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
After increasing number of row you can scroll to the desired row which you wann to show...
Related
I am developing an application in which I need header to customize and add my own button just for single section. I googled and done some code where I am able to add button, but I am facing two issue.
Titles of other's section is not showing.
Button not show properly because of tableview scroll size same after adding button.
Here is what I am doing.
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
UIView * headerView = [[[UIView alloc] initWithFrame:CGRectMake(1, 0, tableView.bounds.size.width, 40)] autorelease];
[headerView setBackgroundColor:[UIColor clearColor]];
if(section==2){
float width = tableView.bounds.size.width;
int fontSize = 18;
int padding = 10;
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(padding, 2, width - padding, fontSize)];
label.text = #"Texto";
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor whiteColor];
label.shadowColor = [UIColor darkGrayColor];
label.shadowOffset = CGSizeMake(0,1);
label.font = [UIFont boldSystemFontOfSize:fontSize];
[headerView addSubview:label];
UIButton * registerButton = [UIButton buttonWithType:UIButtonTypeCustom];
[registerButton setImage:[UIImage imageNamed:#"P_register_btn.png"] forState:UIControlStateNormal];
[registerButton setFrame:CGRectMake(0, 0, 320, 150)];
[headerView addSubview:registerButton];
return headerView;
}
return headerView;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 3;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
if(section==0)
return #"Registration";
else if(section==1)
return #"Player Detail";
return nil;
}
Here is Image of my out put in which Texto text show but button is under that area where the end limit of table view scroll height and also section 0 and 1 title is not showing I also block code for first and second section in viewforheaderinsection. Thanks in advance.
The other header names don't appear because the viewForHeader method only answers for section 2. Once implemented, the datasource expects that method to be the authority on all headers. Just add some else logic for the other sections....
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
UIView * headerView;
UILabel *label;
if (section==2) {
headerView = [[[UIView alloc] initWithFrame:CGRectMake(1, 0, tableView.bounds.size.width, 40)] autorelease];
[headerView setBackgroundColor:[UIColor clearColor]];
// and so on
return headerView;
} else if (section == 0) {
label = [[[UILabel alloc] initWithFrame:CGRectMake(0,0,tableView.bounds.size.width, 44)] autorelease];
label.text = #"Section 0 Title";
return label;
} else .. and so on
The header answered by this method looks to be 40px high (see initWithFrame), but the button being added is 150px high (see setFrame: for the button). That's the likely the root cause of the button issue. Try implementing:
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return (section == 2)? 150.0 : UITableViewAutomaticDimension;
}
I have requirement to scroll the images horizontally and vertically.
I have sections which will segregated vertically and in each section itself it will be so many images which will be scrolled horizontally.
I made vertical scrolling using UICollectionView with Ray wenderlich tutorial but how do I get horizontal scrolling in each section?
Should I use any other object like UITableView or UIScrollview for this purpose?
Any tutorial available how to achieve this?
Is it compulsory to implement Layout subclass or UICollectionviewFlowlayout when using collection view?
EDIT
Till now I have implemented this code which scrolls vertically and has 5 sections each but not able to scroll the individual sections
- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section;
{
NSArray *arrayReturn = [self returnArray:section];
return arrayReturn.count;
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 5;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
ImageCell *cell = [cv dequeueReusableCellWithReuseIdentifier:#"imagecell" forIndexPath:indexPath];
NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
NSArray *arrSection = [NSArray arrayWithArray:[self returnArray:indexPath.section]];
NSString *fileName = [arrSection objectAtIndex:indexPath.row];
UIImage *image = [UIImage imageNamed:fileName];
dispatch_async(dispatch_get_main_queue(), ^{
// cell.imgVw.image = ;
if([CollectionView.indexPathsForVisibleItems containsObject:indexPath]){
ImageCell *currentCell = (ImageCell *) [cv cellForItemAtIndexPath:indexPath];
currentCell.imgVw.image = image;
}
});
}];
[self.thumbnailQueue addOperation:operation];
return cell;
}
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
HeaderView *Header = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:#"PhotoHeaderView" forIndexPath:indexPath];
Header.lblHeaderTitle.text = #"Header title";
Header.backgroundColor = [UIColor yellowColor];
return Header;
}
Here is a similar tutorial:
http://www.raywenderlich.com/4723/how-to-make-an-interface-with-horizontal-tables-like-the-pulse-news-app-part-2
Basically you need to do following:
Take a tableView or CollectionView
In each cell you need to add a scrollview with horizontal scrolling enabled.
Add items to scroll view of each cell while creating cells and give the scroll view appropriate content size.
It will give you a desired result.
Try this
**viewController.h**
IBOutlet UIScrollView *scrollViewMain;
**viewController.m**
- (void)viewDidLoad
{
[super viewDidLoad];
[self createDisplay];
// Do any additional setup after loading the view, typically from a nib.
}
-(void) createDisplay
{
for(UIView *subView in scrollViewMain.subviews)
{
if(![subView isKindOfClass:[UIImageView class]])
{
[subView removeFromSuperview];
}
}
int yPos =5;
for (int i=0; i< 10; i++)
{
int xPosition=5;
UIScrollView *scrollView =[[UIScrollView alloc]initWithFrame:CGRectMake(xPosition, yPos, scrollViewMain.frame.size.width, 100)];
scrollView.backgroundColor =[UIColor clearColor];
scrollView.autoresizingMask =UIViewAutoresizingFlexibleWidth;
xPosition +=5;
for (int j=0; j<10; j++)
{
UILabel *lblTitle = [[UILabel alloc] initWithFrame:CGRectMake(xPosition, 0, 100, 100)];
lblTitle.textColor = [UIColor whiteColor];
lblTitle.backgroundColor =[UIColor greenColor];
lblTitle.text = #"test";
lblTitle.numberOfLines =0;
lblTitle.font = [UIFont boldSystemFontOfSize:15];
[scrollView addSubview:lblTitle];
xPosition +=100;
xPosition +=10;
}
[scrollView setContentSize:CGSizeMake(xPosition, 100)];
[scrollViewMain addSubview:scrollView];
yPos +=120;
}
[scrollViewMain flashScrollIndicators];
[scrollViewMain setContentSize:CGSizeMake(0, yPos)];
}
I want to display a table with custom header titles.
The table view is attached to a controller class that implements the tableview delegate and data source protocols but is not a subclass of UIViewController because the table is a subview to be displayed above another tableview.
some snippets of my code:
The tableview is created programmatically:
_myListView = [[UITableView alloc] initWithFrame:tableFrame style:UITableViewStyleGrouped];
[_myListView setDataSource:self.myListController];
[_myListView setDelegate:self.myListController];
[_myListView setBackgroundColor:darkBackgroundColor];
where myListController is a strong property in the class.
For the number of rows in sections:
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
…
return count;
}
The number of sections:
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return [someDelegate sectionCount];
}
For the custom Header View:
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView* headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, SectionHeaderHeight)];
UILabel* sectionHeaderTitle = [[UILabel alloc] initWithFrame:CGRectMake(20, 3, 300, 24)];
[headerView setBackgroundColor:[UIColor clearColor]];
sectionHeaderTitle.text = [self myTitleForHeaderInSection:section];
sectionHeaderTitle.textColor = [UIColor whiteColor];
sectionHeaderTitle.textAlignment = UITextAlignmentLeft;
[headerView addSubview:sectionHeaderTitle];
return headerView;
}
For the custom headerViewHeight (as required since iOS5):
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if ( [self tableView:tableView numberOfRowsInSection:section] > 0) {
return SectionHeaderHeight;
} else {
return 0;
}
}
Sadly, the tableview does not display any section headers just as if I would return nil.
However, I have checked with a breakpoint, that the code actually returns an UIView.
Everything else works fine.
What am I missing? PLease, don't hesitate to make me feel ashamed of my self.
I don't really understand why you want to use a custom view, and not the "standard" one ? You may have your reasons, but I don't see anything in your code telling me why :)
I would personally just use this:
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
if (section == 0) return #"First section header title";
if (section == 1) return #"Second section header title";
else return nil;
}
Tell me if that's not what you're looking for !
I seem to have found a solution:
I have created a lazy loading strong property for each header view I want to display. (luckily there are only three)
Now the views are shown.
It seems that the header views got deallocated without the strong references before the table was rendered.
Could it be that there is a connection to the class implementing the table view delegate and data source protocols is not a UIViewController?
Text Color you change it to Black color and check once.
sectionHeaderTitle.textColor = [UIColor blackColor];
you try this code this work on my side :-)
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 24)];
UIImage *myImage = [UIImage imageNamed:#"SectionBackGround.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:myImage];
imageView.frame = CGRectMake(0,0,320,24);
UIImage *imageIcon = [UIImage imageNamed:#"SectionBackGround.png"];
UIImageView *iconView = [[UIImageView alloc] initWithImage:myImage];
iconView.frame = CGRectMake(0,0,320,24);
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 24)];
label.text = [tableView.dataSource tableView:tableView titleForHeaderInSection:section];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont boldSystemFontOfSize:14];
[view addSubview:imageView];
[view addSubview:iconView];
[view addSubview:label];
return view;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 24;
}
While I was running my application on simulator everything was working fine. Including the orientation of all views. Now, when I tested the application on my Ipad, I noticed an issue which I think I must take care of.
I have a UITableView which has a UILabel, UITextView and a UIButton in each of its row. The problem I am facing is, when I type something on the textview, and in between change the orientation, the text disappears along with the keyboard. Although I know the reason for this is the reloading of tableview which I do every time I change the orientation, I am not able to handle it. Reloading of tableview is also important for other views to be oriented properly.
What needs to be done?
Update
- (void)viewDidLoad
{
[super viewDidLoad];
checkTextView = FALSE;
self.title=#"Tasks";
arrTextViews = [[NSMutableArray alloc]init];
[self checkOrientation];
// Do any additional setup after loading the view from its nib.
}
-(void)viewWillAppear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(receivedRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
}
-(void)viewWillDisappear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
}
-(void) checkOrientation
{
UIInterfaceOrientation orientation = self.interfaceOrientation;
#try
{
if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {
textXX=340.0;
btnXX=900.0;
textLL=480.0;
[commentsTable reloadData];
}
else if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) {
textXX=240.0;
btnXX=650.0;
textLL=350.0;
[commentsTable reloadData];
}
}
#catch (NSException *ex) {
[Utils LogExceptionOnServer:#"TodayViewController" methodName:#"checkOrientation" exception:[ex description]];
}
}
- (void)receivedRotate:(NSNotification *)notification
{
[self checkOrientation];
}
// Customize the number of sections in the table view.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [arrComments count];
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil] autorelease];
}
cell.selectionStyle=UITableViewCellSelectionStyleNone;
// Configure the cell
NSArray *arrSeparate = [strName componentsSeparatedByString:#":"];
NSString *str1 = [arrSeparate objectAtIndex:0];
NSString *str2 = [arrSeparate objectAtIndex:1];
lblName1=[[UILabel alloc]init];
lblName1.frame=CGRectMake(10, 13, 200, 30);
lblName1.numberOfLines=1;
[lblName1 setText:str1];
[lblName1 setTextColor:[UIColor colorWithRed:0.0/255.0 green:73.0/255.0 blue:121.0/255.0 alpha:1.0]];
[lblName1 setFont:[UIFont boldSystemFontOfSize:25.0]];
[lblName1 setBackgroundColor:[UIColor clearColor]];
[cell.contentView addSubview:lblName1];
[lblName1 release];
lblName2=[[UILabel alloc]init];
lblName2.frame=CGRectMake(10, 50, 200.0, 70);
lblName2.numberOfLines=2;
[lblName2 setText:str2];
[lblName2 setTextColor:[UIColor colorWithRed:0.0/255.0 green:73.0/255.0 blue:121.0/255.0 alpha:1.0]];
[lblName2 setFont:[UIFont boldSystemFontOfSize:25.0]];
[lblName2 setBackgroundColor:[UIColor clearColor]];
[cell.contentView addSubview:lblName2];
[lblName2 release];
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(textXX-1, 12, textLL+2, 132)];
imgView.image = [UIImage imageNamed:#"box.png"];
[cell.contentView addSubview:imgView];
[imgView release];
//txtComment
txtComment = [[UITextView alloc] initWithFrame:CGRectMake(textXX,13, textLL, 130)];
txtComment.scrollEnabled = YES;
txtComment.userInteractionEnabled = YES;
txtComment.tag=indexPath.row;
iTextViewTag = txtComment.tag;
strGetText = txtComment.text;
[txtComment setTextColor:[UIColor colorWithRed:0.0/255.0 green:73.0/255.0 blue:121.0/255.0 alpha:1.0]];
[txtComment setFont:[ UIFont boldSystemFontOfSize: 25 ]];
[cell.contentView addSubview:txtComment];
[arrTextViews addObject:txtComment];
[txtComment release];
UIImageView *imgBtn = [[UIImageView alloc] initWithFrame:CGRectMake(btnXX-1, 12, 72, 132)];
imgBtn.image = [UIImage imageNamed:#"commentbbtnbox.png"];
[cell.contentView addSubview:imgBtn];
[imgBtn release];
//btnClose
btnClose = [UIButton buttonWithType:UIButtonTypeCustom];
btnClose.frame=CGRectMake(btnXX, 13,70,130);
btnClose.tag= indexPath.row;
btnClose.backgroundColor = [UIColor grayColor];
[btnClose addTarget:self action:#selector(btnCloseAction:) forControlEvents:UIControlEventTouchDown];
[cell.contentView addSubview:btnClose];
return cell;
}
One solution (maybe not the best) would be to save the text and the indexPath of the row being edited just before the rotation occurs. When the rotation is finished, you'll just have to restore the text and the focus. Use the following messages in your tableview controller:
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation duration:(NSTimeInterval)duration
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
See here, if these messages are not called.
My problem is I have a Custom button and ImageView to which I added the Image.I made this imageView to the custom button as a subview.when Im running it in simulator it workin fine,but when Im runnig it in Device it was not displaying the image in the button.
I written the code as:
In cellForRowtIndexPath
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"MasterViewIdentifier"];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:#"MasterViewIdentifier"] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UIView* elementView = [[UIView alloc] initWithFrame:CGRectMake(20,170,320,280)];
elementView.tag = 0;
elementView.backgroundColor=[UIColor clearColor];
[cell.contentView addSubview:elementView];
[elementView release];
}
UIView* elementView = [cell.contentView viewWithTag:0];
elementView.backgroundColor=[UIColor clearColor];
for(UIView* subView in elementView.subviews)
{
[subView removeFromSuperview];
}
if(indexPath.section == 8)
{
imageView.image = [UIImage imageNamed:#"yellow_Star.png"];
MyCustomButton *button1 = [[MyCustomButton alloc]initWithRating:1];
[button1 setFrame:CGRectMake(159, 15, 25, 20)];
[button1 setShowsTouchWhenHighlighted:YES];
[button1 addTarget:self action:#selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
[button1 addSubview:imageView];
[elementView addSubview:button1];
[button1 release];
[imageView release];
}
return cell;
}
and in my buttonAction:
-(void)buttonAction:(MyCustomButton*)sender
{
rating = [sender ratingValue];
event.eventRatings = rating;
[tableView reloadData];
}
and i MyCustomButton class:
i have a method as
-(MyCustomButton*) initWithRating:(NSInteger)aRatingValue
{
if (self = [super init])
{
self.ratingValue = aRatingValue;
}
return self;
}
pls help guys from dis problem.
Thank you,
Monish.
You're trying to load image named "yellow_Star.png" - check if it actually named so (with the same characters case). File system on iPhone is case sensitive and on Mac OS is not - so it is often causes such problems and file names is the first thing to look at.
Edit: You can also try to check if the image is present in the application bundle - may be it was removed from copy resources build step by chance, that is your image must be in a "Copy Bundle Resources" build step for your build target. If it is absent you can just drag and drop your image there.