I want to know how can i put UITableViewCellEditingStyleInsert on the right in UITableView like in this picture:
You can create a UIButton with the type UIButtonTypeContactAdd and add it as an accessory view:
UIButton *accessory = [UIButton buttonWithType:UIButtonTypeContactAdd];
[cell setAccessoryView:accessory];
The icon is blue, though; if you want it to be green like UITableViewCellEditingStyleInsert, you have to make a button with a custom image instead of using UIButtonTypeContactAdd.
Related
I would like to create something like this:
I would like to place an UITextField with an UIButton into one grey frame, and I would like the button's border to be contained by this grey frame.
Please somebody show me some sample code for this!
Thx!
1. Use a UIImageView of required rect. Set the background image to the gradient gray colour image.
UIImageView*myImageView=[[UIImageView alloc] initWithFrame:yourFrame];
[myImageView setImage:[UIImage imageNamed:#"grayBackground.png"];
[self.view addSubview:myImageView];
2. Use a round rect. UITextField make it a subview of the image view. Use a place holder as "Write a reply..." make it a subview to your imageview.
UITextField*myField=[[UITextField alloc] initWithFrame:yourRect];
[myField setBorderStyle:UITextBorderStyleRoundedRect];
[myField setPlaceholder:#"Write a reply..."];
[myImageView addSubview:myField];
3. Use a UIButton with type Custom and the send image as its background image, make it a subview to your imageview.
UIButton*myButton=[UIButton buttonWithType:UIButtonTypeCustom];
[myButton setFrame:yourRect]
[myButton setBackgroundImage:[UIImage imageNamed:#"sendImage.png"] forState:UIControlStateNormal];
[myImageView addSubView:myButton];
Simple way is to create title bar with grey background and delete the title.and place textfield and button which u want to place it.configure the size and button outside the title bar and drag it to the title bar..u'll get like the image which u have got.
I want to customize the accessory view of a UITableViewCell, so I need a UIImage.
I want that image to be like the "Add Contact" type button (That blue plus).
How can I do that?
You can achieve that by creating a UIButton with the UIButtonTypeContactAdd type and adding it as the accessoryView of your cell.
UIButton contactAddButton = [UIButton buttonWithType:UIButtonTypeContactAdd];
cell.accessoryView = contactAddButton;
Solved it. If I set user interaction disabled it just does not have a click interaction and behaves like an image.
UIButton *contactAddButton = [UIButton buttonWithType:UIButtonTypeContactAdd];
[contactAddButton setUserInteractionEnabled:FALSE];
cell.accessoryView = contactAddButton;
You can get one here: http://blog.twg.ca/2010/11/retina-display-icon-set/
Hi
In my app, i have a requirement to make this grid view..type....i want to do it by UITableView...(Although done via scroll view)
My Query is , by using custom cell, in 1 row, there will be 1 custom cell with 4 image view in it...
so now on image tapping how will i know which image inside cell is tapped????
or second option i thought..as each image as custom cell..but dont know how to proceed furthur....as how can we get 2 adjacent cell in 1 row????
Also wanna know which method is better...as this grid view will be containing 50 images around....and on tapping bigger view opens with scrolling...
Thanks
What you can do is create a custom UIButton inside the UIView and set a background image and a selector.
Something like this :
UIButton *button = [[UIButton buttonWithType:UIButtonTypeCustom] initWithFrame:CGRectMake(0, 0, 24, 24)];
[button addTarget:self action:#selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
[button setBackgroundImage:[UIImage imageNamed:#"someImage.png"] forState:UIControlStateNormal];
[buttonHolder addSubview:button]; //buttonHolder will be one of the UIView in your cell
i have create image gallery view using scroll view gallery view
if you want to make in table view you have to create custom cell with 4 image view and a single button each image attached with image tag when a button pressed it get the tag number and you can find which of image button is clicked.
Actually the question is simple. I don't know what to add to the title of my question. I need to have button which has border and title and nothing else. The rest is transparent and background of my view is seen through the button. I have googled for it a lot and found nothing. Thanks in advance
You can make the button of type UIButtonTypeCustom and add a border to its CALayer.
[[myButton layer] setCornerRadius:10];
[[myButton layer] setBorderColor:[[UIColor blackColor] CGColor]];
[[myButton layer] setBorderWidth:2];
you need to #import <QuartzCore/QuartzCore.h> to use the layer's methods.
EDIT (Answer to comments)
If you created the button in Interface Builder and connected to the proper outlet, then you shouldn't create a new button in code, which is what you're doing with
backArrowButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
When you added the button in Interface Builder and connected it to the outlet, you already created it there, so just make sure that in IB it's set to Custom, and just set the layers properties in code like shown above.
Yes, just make your graphic completely transparent with the border you want. Then:
UIButton* button = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
[button setImage:[UIImage imageNamed:#"YOUR-IMAGE" forState:UIControlStateNormal];
...
I'm trying to add a UIButton to a UIView, but am having some trouble with getting it to respond to touches.
I have a method which returns UIButtons after I provide it with a tag:
- (UIButton*)niceSizeButtonWithTag:(int)tag {
UIButton * aButton = [UIButton buttonWithType:UIButtonTypeCustom];
[aButton setTag:tag];
[aButton addTarget:self action:#selector(buttonWasTapped:) forControlEvents:UIControlEventTouchUpInside];
CGRect newFrame = aButton.frame;
newFrame.size.width = 44;
newFrame.size.height = 44;
[aButton setFrame:newFrame];
return aButton;
}
As you can see I'm creating a new button and increasing the size.
I use this in the following way:
UIButton * anotherButton = [self niceSizeButtonWithTag:1];
[anotherButton setImage:[UIImage imageNamed:#"image" withExtension:#"png"] forState:UIControlStateNormal];
[anotherButton setCenter:CGPointMake(middleOfView)];
[aView addSubview:anotherButton];
I create a lot of buttons like this, hence the reason for the method.
The buttons are always created and added to the subview perfectly. I can see the image and they're in the correct position. The problem is that they only respond to touches in a tiny strip.
In this attached image,
alt text http://web1.twitpic.com/img/107755085-5bffdcb66beb6674d01bb951094b0e55.4c017948-full.png
The yellow shows the whole frame of the button,
The red shows the area that will respond to touches.
The grey shows a section of the view the button is added to.
If anyone could shed some light on why this is happening, it would be really useful.
UPDATE:
I should probably mention I'm trying to add this button to a UIView which is a subview of a UITableViewCell.
UPDATE 2:
Adding it directly to the UITableViewCell works, adding it to the UIView on the UITableViewCell is causing the error.
FINAL UPDATE
The problem turned out to be that I was sending the view containing the button to the back of the subviews on the UITableViewCell. Getting rid of the sendSubviewToBack: call fixed it.
Do you have any other views added to this containing view after you add the button? try setting some of your view's background color to blueColor, redColor and other colors to better see what the stack of views in your app is like. Then you should be easily able to see if there is some sort of view blocking the button.