see below figure, it has- TableView & tablecell have same background image i.e.tableview & tablecell must not look different. in tableCell there must be one button .
To achieve this you'll have to create a customized UITableViewCell.
You'll required 4 background image for your cell.
a. Image Facing right. b. Rollover image facing right. c.
Image Facing left. d. Rollover image facing left.
You'll have to set alternate image to your cell. And when you click on the cell you'll need to change the background image of that particular cell to Rollover image.
Also you'll have to manage the frames of your rest of the control accordingly.
This is nothing but the image. You have to set an image in every tableviewcell by passing the condition
if(indexpath.row/2 == 0)
<set_image1>
else
<set_image2>
then adjust other parameters according to your desired frame position.
Note: You need to use dynamic tableviewcell height &
You need for images for this.Two when cell is not selected & rest two when cell got selected
Enjoy Programming!
I did this following way:
I created two prototype cells having different Cell identifier
e.g. left cell identifier= Cell1 & right cell identifier=Cell2.
simply put one round-rect button, make it as custom because it shows only in image shape
made table cell background color as clearColor, it requires because for the feel of table cell & tableview must look same.
also set tableView background color as clearColor & add images to both button.
if ((indexPath.row)%2!=0)
{
CellIdentifier=#"Cell1";
}
else
{
CellIdentifier=#"Cell2";
}
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
UIButton *topicButton=(UIButton *)[cell viewWithTag:1];
NSString *topicNameLabel=[_topics objectAtIndex:indexPath.row];
Related
In Swift,I have a tableview and in that many tableview cells. In the tableview cell I have a UIImageView in which there is an Image . So now I want to dynamically change the colour of the image everytime the tableview loads,so that the image is visible to the user and the transparent colours on the images are maintained everytime the reload of the table happens.
Suppose there is - 1 TableView - multiple cells
- cell1(UIImageView - transparent redcolor) - UIImageView(tranparent bluecolor) - cell3(transparent yellowcolor) so on........how to do it dynamically?
You have two options:
configure the bleeding color in cellForRowAtIndexPath. Specifically you need to set the .backgroundColor property on the UIImageView that holds the image.
have a configureWithColor method in the custom cell (if you have a custom cell) and do the color configuration there.
I want to create a custom cell for uitableview with an image at left side such that the following things happen
1)When the cell is selected , its height is increased , background color is changed and it gets a green color circular button at the position of accessory view
MY APPROACH :- I made a custom uiview such that it contains an imageview at the position of accessory view ,
and then i did
[[table cellForRowAtIndexPath:indexPath].contentView addSubview:customCellBackgroundView];
but this didnt work , because it hide the cell's text
2)the selected should remain of the same height , such that more than one cell can be selected and the selected cells have larger heights than the unselected ones
You can keep a property for each cell that says if it is selected or not. When drawing each cell you check to see if that cell is supose to be selected or not and use 1 of 2 different cell layouts you previously created (one collapsed and the other opened).
So when you click some cell, you change the selected state of that cell and call for a reload of the tableview so that the same cell is now drawn as opened/closed.
I am saving the indexPath selection from a subview and passing it to the parent view with delegates. When I got back to my subview from my main view I pass the indexPath back to it and show the user which cell they previously selected with a tick in the accessory view of the tableviewcell.
One problem being if the user has selected a cell out of a fairly big list its hard to find the cell they selected again incase they wanted to change it (being that they made a mistake)
I would like to know if their is a way to use indexPath or something similar to center the previously selected cell of the uitableview to the center of the screen?
UPDATE::
Here is a graphical view of what I am trying to achive to make it abit more understandable..
step one : select cell then go to subview and select the cell (value) you want to pass back to main view (save indexPath of selected cell)
step two: user either wants to change his selection or made a mistake and was ment to select the cell below the one they chose... repeat previous steps but display previously selected cell in the center of the view..
Have you tried the following function
[tableView scrollToRowAtIndexPath: atScrollPosition:UITableViewScrollPositionMiddle animated:YES]
a UITableView is a subclass of UIScrollView - try setting the Content Offset (figure out how much with the cell height and indexPath).
[tableView setContentOffset:CGPointMake(0, indexPath.row*cellHeight) animated:YES];
should work. You might want to do the math a little differently.
I have a tableView and you can add cells. and it doesnt show my image on the left hand side of the newly added cells. I'm using the default cell style and here is my code:
This is the button that allows us to add a cell.
- (IBAction)outlet1:(id)sender {
[cart.cells addObject:#"1"];
cart.cell.imageView.image = [UIImage imageNamed:#"paddle1.png"];
}
Please help! I checked the name of the image and it seems good. Thanks!
It would be better to place the image to the UITableViewCell inside the cellForRowAtIndexPath method, by setting the image to cell.imageView.image
I want to customize UITableViewCell by adding UILabel and two UIButton as its subview.
The cell style will be UITableViewCellStyleSubtitle and these three items would have to
next (on the left) of detailTextLabel.But when i do this, detailTextLabel overlaps with these items and display clipped or partial subviews.
Any way to handle out this without subclassing UITableViewCell if possible.
Thanks.
do you want to display something with detailTextLabel? If not you could try to hide it.
cell.detailTextLabel.hidden = YES;
otherwise you could add another Label at a better position which displays your detailText